PDA

View Full Version : a crontab template and some hints



lsatenstein
17th December 2014, 11:32 PM
################################################## ################################################## ########
# ##
#mm hh DoM Mon Dow CMD # minute, hour, month-day month DayofW CMD ##
#........................................Minute of the hour ##
#| ................................Hour in the day (0..23) ##
#| | .........................Day of month, 1..31 ##
#| | | .................Month (1.12) Jan, Feb.. Dec ##
#| | | | ........day of the week 0-6 7==0 sun,mon,tue ##
#| | | | | |command to be executed ##
#V V V V V V ##
15 3 * * * sudo find $HOME -name core 2>/dev/null | xargs rm -f >/dev/null 2>&1
0 0 31 1 * mailx sombody%Happy New Year!%Time for Resolutions ##
0 2 * * mon,wed,fri sudo yes | yum update -y # yum update 2am m-w-f ##


If you are creating a crontab with multiple entries, and you as yet do not have a crontab
take the above example and download it to a file. Revise it for your needs.
Subsequently run

cat fileToUse | crontab -e

For day of the week, you may substitute mon,tue,wed,thur,fri,sat,sun. Sunday is day 0 = day 7
Wondering about /usr/bin/yes?
this program emits y followed by enter "y\n"

If you are running yum and you have some certificate updates, and you know who or what, and you really want to run automatically when you are not around, accepting the certificates, use the yes program to respond y. The -y only tells yum to proceed. the yes tells yum to accept the certificate.

One thing to mention. When chron starts your application, the basic environment is present. be sure that your application has set the necessary path and environment variables.

For more info info cron from the command line. (terminal).

.