Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (11) AWS (5) numerology (5)

Tuesday, March 6, 2018

How to run cronjob at 5 hours interval + Linux


How to run cronjob at 5 hours interval + Linux

In our day to day task, we get request of cron job scheduling so the script/service will run after certain time interval.

If we want our cronjob (eg. restarting rsyslog service) to run after every 5 hours, then we can edit crontab with below entries:

1. Edit crontab file, it will edit the crontab file of root user.

[root@cloud home]# crontab -e

2Make below entry:

0 */5 * * *

[root@cloud home]# 0 */5 * * * systemctl restart rsyslog

Or

0 5,10,15,20 * * *

[root@cloud home]# 0 5,10,15,20 * * * systemctl restart rsyslog

3 List crontab file:

[root@cloud home]# crontab -l

Crontab fields:
= * - first * shows minutes [0-59]
= * - second * shows hour [0-23]
= * - third * shows Day of month [1-31]
= * - Fourth * shows month [0-12]
= * - Fifth * shows day of week [0-7]


Regards,
Kiiran B Jadhav

No comments:

Post a Comment