0

Cronjob is not working on server properly, when i am adding any cron like for every 1 hour or every 2 hour and after restarting cron service cronjob execute those script in every 1 minute.

And when i'm giving any exact time for executing any script it works properly.

cronjob like its for every 1 hour but it runs in every 1 minute

* */1 * * * python3 /var/wwwroot/script.py

How do i resolve this problem.

1

1 Answer 1

1

For every hour, you want:

0 * * * * python3 /var/wwwroot/script.py
  1. 0 = Run at '0' minutes past hour
  2. * = Run every hour of the day
  3. * = every day of month
  4. * = every month of year
  5. * = every day of week

For every 2 hours, at 30m past the hour you want:

30 */2 * * * python3 /var/wwwroot/script.py

Reference:

4
  • For every half hour or 2 hour what will be cronjob?
    – shiva
    Apr 25, 2018 at 5:05
  • edited answer to incorporate
    – dpb
    Apr 25, 2018 at 5:10
  • Thanks dpb, One more que: is there any recent changes in crontab syntax?
    – shiva
    Apr 25, 2018 at 5:20
  • not really. I think the most recent are the aliases. that let you type out things like @hourly /run/this/script, but again, see man 5 crontab for more info
    – dpb
    Apr 25, 2018 at 5:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .