Crontab

(Redirected from Crontab daily script)


To run a script periodically you have to register the script to your CRONTAB.


On old Linux versions you can edit the crontab directly ; while on modern one you should put your script inside a specific folder.


Crontab manual edition (old)

crontab -e


Just add some new entry like:

# m h  dom mon dow   command
0 2 * * * /root/bin/daily_backup > /root/logs/backup_$(date +\%Y\%m\%d).log



Crontab manual edition (new)

Instead of editing the cron, just put your script in the right folder:

  • /etc/cron.hourly
  • /etc/cron.daily
  • /etc/cron.weekly
  • /etc/cron.monthly

All scripts must belong to root:root and have the 755 permissions.


!!! NOTE !!!

You must NOT put a '.' instead your filename! See: http://askubuntu.com/questions/502592/ubuntu-14-04-not-running-bash-scripts-in-etc-cron-daily


  • /etc/daily/vehco-cron.sh <<< KO - it will NOT run
  • /etc/daily/vehco-cron <<< OK