Quantcast
Channel: Syed Jahanzaib – Personal Blog to Share Knowledge !
Viewing all articles
Browse latest Browse all 409

CRON examples ! Focus and save yourself from embarrassment !

$
0
0

cron examples

 

To add scheduled job in linux/ubuntu, use

crontab -e

To view installed cron

crontab -l

Examples:

Run Script at Every 1st day of Month.

@monthly /temp/script.sh

Run Script Daily at 00:00 hours (midnight)

@daily /temp/script.sh

Run Script every hour 

@hourly /temp/script.sh

Run Script every minute

* * * * * /temp/script.sh

Run Script after every 5 minutes

*/5 * * * * /temp/script.sh

Run Script on Specific Timings And Date of Months, Example run script on 10am and 11am  on 12th of every month.

00 10,11 12 * * /temp/script.sh

Run Script on Specific Hours of Every Month, Example run script on 9am of every month.

00 9 10 * * /temp/script.sh

Run Script on Specific Hours RANGES , Example run script on 10am to 8pm , means every hour from 10am-8pm

00 10-20 * * * /temp/script.sh


Shortcuts in CRON

@reboot        Run once, at startup.
@yearly        Run once a year, "0 0 1 1 *".
@annually      (same as @yearly)
@monthly       Run once a month, "0 0 1 * *".
@weekly        Run once a week, "0 0 * * 0".
@daily         Run once a day, "0 0 * * *".
@midnight      (same as @daily)
@hourly        Run once an hour, "0 * * * *".


 


Filed under: Linux Related

Viewing all articles
Browse latest Browse all 409

Trending Articles