/etc/crontab 30 19 * * * root shutdown -h now
spool crontabs/root spool root
- Minute [0,59]
- Hour [0,23]
- Day of the month [1,31]
- Month of the year [1,12]
- Day of the week ([0,6] with 0=Sunday)
You can define environment variables in the crontab itself when running crontab -e from the command line.
LANG=nb_NO.UTF-8 LC_ALL=nb_NO.UTF-8 # m h dom mon dow command * * * * * sleep 5s && echo "yo"
This feature is only available to certain implementations of cron. Ubuntu and Debian currently use vixie-cron which allows these to be declared in the crontab file (also GNU mcron).
Note that you can't use variable substitution as in shell, so a declaration like PATH=/usr/local/bin:$PATH is interpreted literally and does not work as expected.
Archlinux and RedHat use cronie which does not allow environment variables to be declared and will throw syntax errors in the cron.log. Workaround can be done per-entry:
# m h dom mon dow command * * * * * export LC_ALL=nb_NO.UTF-8; sleep 5s && echo "yo"
grep CRON /var/log/syslog
Feb 15 12:00:01 istest CRON: (root) CMD (/root/files/scripts/work_a.sh) Feb 16 00:30:01 istest CRON: (root) CMD (/root/files/scripts/work_b.sh)