From my understanding you can write your crons by editing
crontab -e
I've found several sources that instead refer to a bash script in the cron job, rather than writing a job line for line.
Is the only benefit that you can consolidate many tasks into one cron job using a bash script?
Additional question for a newbie: Editing crontab -e refers to one file correct? I've noticed that if I open crontab -e and close without editing, when I open the file again there is a different numerical extension such as:
"/tmp/crontab.XXXXk1DEaM" 0L, 0C
I though the crontab is stored in /var/spool/cron or /etc/crontab ??
Why would it store the cron in the tmp folder?
Answer
It depends on what you're doing with the job.
cron does not give you a real scripting environment, so, if you're doing something more complicated than simply calling a couple of commands, you probably want to use cron to call a script. You can also deal with things like variable expansion in a script, which can be difficult if not impossible to do in cron's environment.
The temporary file that you see when you run crontab -e
is just that: a temporary file that will be cleaned up after you exit the editor session. The actual crontabs that you edit through this method wind up in /var/spool/cron.
Actually, since these are relatively basic unix-specific questions, there's the unix.stackexchange.com side of things, which may be more helpful.
Comments
Post a Comment