CRON commands, help, tips

Random tips and commands to make cron even more use-able and useful

At the terminal type the following to list the cron jobs schedulated for the current user
crontab -l

At the terminal type the following to edit the current usres crontab
crontab -e

Add the following to cron to stop the system emailing you notifications
MAILTO=""

The five stars that set cron scheduling options are as follows:
* * * * * = MINUTE - HOUR - DAY OF MONTH - MONTH - DAY OF WEEK

Dump / backup a mysql database (in this case at 11:10pm every Monday)
10 23 * * 1 mysqldump -XXX -pXXX DATABASE > /var/www/vhosts/DOMAINNAME/FOLDER/DATABASE.sql

Command to remove all text files from specific directory (in this case every week)
@weekly find /var/www/vhosts/DOMAIN/DIRECTORY -name "*.txt" | xargs rm

Run script etc on reboot using cron. Instead of using ***** you can use the @reboot command.
@reboot sleep 60;/path/to/Script.sh

Other simple commands that you can use instead of ***** are:
@daily
@midnight
@weekly
@monthly
@yearly

Print Friendly, PDF & Email

More Like This


Categories


Linux

Tags


  • Post a comment