Installing and running cronjob (crontab basics)

>Basic commands to open/Edit crontab fileEditing crontab file
crontab -eDisplaying crontab file
crontab -lRemove crontab
crontab -rcrontab syntaxcron command basically takes 6 input parameters of which each input can take multiple argumentsfor that one can make use of comma or pipe separator
# min hour dom mon dow command* * * * * (command)Here * means for every. Above command will get executed for every minute
Detailed syntax* * * * * command to be executed- – – – -| | | | || | | | +—– day of week (0 – 6) (Sunday=0)| | | +——- month (1 – 12)| | +——— day of month (1 – 31)| +———- hour (0 – 23)+——- min (0 – 59)Example commands
# Generate progressive report for every active user at 11:45 p.m.45 23 * * * (cd /home/sandip/current/; rake ace:daily_progressive_report RAILS_ENV=production)# Take database backup every night59 2 * * * (cd /home/sandip/current/; rake db:backup RAILS_ENV=production)# Initialize grouping on database every sunday29 3 * * 0 (cd /home/sandip/current/; rake ace:initializeCarGrouping RAILS_ENV=production)# Generate daily stats on 4:30 AM & 12:30 PM and 4:30 PM30 4,12,16 * * * (cd /home/sandip/current/; rake ace:daily_call_statistics RAILS_ENV=production)# Rotate sphinx indexes updated evry hour if missed out somehow0 * * * * (cd /user/local/bin/; indexer –rotate –config /home/sandip/current/config/production.sphinx.conf)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.