http://Bj83.de

crontab and cronjobs

write your command best in a shellscript and add runnable to it

chmod +x /home/scripts/yourscriptfile.sh

 

add it to /etc/crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
*/1 * * * * root /home/scripts/yourscriptfile.sh >> /home/cron_scripts/global_cron_script.log

only use “tab” between fields

*/x means reapeat every x

further details @ http://www.adminschoice.com/crontab-quick-reference/

then restart/reload cronjobs

/etc/init.d/crontab restart

 

1 comment for “crontab and cronjobs

  1. 04/12/2014 at 13:41

    using different editor
    env EDITOR=nano crontab -e

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: