Cron
Jump to navigation
Jump to search
Scheduled tasks in a linux environment are handled by the cron daemon. The daemon is already running on your system.
To set up your own cron jobs, create a file called crons.cron.
$ sudo nano -w crons.cron
The example below calls a script called dbbackup every day at 3am, calls a php file called logimport every minute, and performs a clamav virus scan of the web root, tmp and home directories excluding the warpath folder at 8am on Sundays.
#Min Hour Day Month DOW 0 3 * * * /usr/bin/dbbackup */1 * * * * /usr/bin/php -q /var/www/localhost/htdocs/logimport.php > /dev/null 0 8 * * 0 /usr/bin/clamscan -r --quiet --remove --no-summary -i -l /var/log/clamav/clamscan.log /var/www/localhost/htdocs/ /tmp /home --exclude-dir=/home/gr0x0rd/warpath
To add these to the cron schedule,
$ sudo crontab //path/to/crons.cron
To stop the cron jobs in order to edit or change them,
$ sudo crontab -r
Use nano to alter your crons.cron file, then use the command above to restart the tasks.