var/spool/cron/ or /var/cron/tabs/ is directory for personal user crontab files. All individual user must must use crontab command to install and edit their jobs as described above. Usually only used by root user or daemons to configure system wide jobs. Make a backup everyday: /path/to/backup/script.sh More about /etc/crontab file and /etc/cron.d/* directories Run ntpdate command every hour: /path/to/ntpdate Special once, at once a year, “0 0 1 1 as once a month, “0 0 1 * once a week, “0 0 * * once a day, “0 0 * * as once an hour, “0 * * * *”. It will not just save your time but it will improve readability. Instead of the first five fields, you can use any one of eight special strings. # crontab -r -u username Use special string to save time To remove or erase all crontab jobs use the following command: See “ Disable The Mail Alert By Crontab Command” for more information. To mail output to particular email account let us say you need to define MAILTO variable as follows: 3 * * * /root/backup.sh >/dev/null 2>&1 For example: 0 3 * * * /root/backup.sh >/dev/null 2>&1 ![]() To stop receiving email output from crontab you need to append >/dev/null 2>&1. Steps are also permitted after an asterisk, so if you want to say every two hours, just use */2.īy default the output of a command or a script (if any produced), will be email to your local email account. The separator (/) : This operator specifies a step value, for example: “0-23/” can be used in the hours field to specify command execution every other hour.The dash ( -) : This operator specifies a range of values, for example: “5-15” days, which is equivalent to typing “5,6,7,8,9,….,13,14,15” using the comma operator.The comma ( ,) : This operator specifies a list of values, for example: “1,5,10,15,20, 25”.For example, an asterisk in the hour time field would be equivalent to every hour or an asterisk in the month field would be equivalent to every month. ![]()
0 Comments
Leave a Reply. |