Restart Crontab on FreeBSD and Linux

Cron is one of the most useful utilities in FreeBSD. Cron is application that running in background that checks file /etc/crontab constantly, it is usually used for automatic commands execution. Using cron and this crontab file you can also start any service you want automatically or scheduled.

1. to change crontab or edit crontab file (using ee or vi)
ee /etc/crontab

you will see lines like this

PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute   hour   mday    month   wday   who   command
#
*/5            *           *          *             *          root   /usr/libexec/atrun
*                 */2      *          *             *          root   sh /root/download.sh

by reading it you will understand that you just need to edit or add lines and commands, like the example given. for example, i want to automatically erase files in directory every 30 days that is on 1st day of each month. i can add this line

#minute   hour   mday    month   wday   who   command
0               0         1            *            *           root   rm -r /home/administrator/file

2. Save it and restart cron

to restart cron on FreeBSD
simply type this command

/etc/rc.d/cron restart

to restart cron on linux, ubuntu
type this command

/etc/rc.d/cron restart

this is the time reference to edit crontab

min    hour    mday   month   wday   Execution time
30       0           1           1,6,12      *           00:30 Hrs on 1st of Jan, June & Dec.
0         20        *           10         1-5           8.00 PM every weekday (Mon-Fri) only in Oct.
0         0          1,10       *              *            midnight on 1st & 10th  of month
5,10    0          10          *             1             At 12.05,12.10 every Monday & on 10th of every month