0

I set up an anacron job:

1@hourly 0 name wget https://mydomain.com/actions/controller  

So it runs hourly but I did not choose the time:
7:33 then 8:33 then 9:33 ...

Is it possible to define precisely the time to run as:
7:00 then 8:00 then 9:00 ...

Note: my hosting provider give me no choice between cron and anacron, only anacron is available on my virtual server.

4

No, anacron may not be used to schedule jobs for running at exact times like that. It is best used for making sure that, for example, maintenance script gets run at approximate frequencies, like daily, weekly, or monthly. It does not have a time resolution lower than one day.

Personally, I launch anacron from an @hourly and a @reboot cron job (on my OpenBSD machine that isn't running 24/7), and it takes care of the daily, weekly, and monthly tasks if those tasks needs doing:

@hourly /usr/local/sbin/anacron -s
@reboot /usr/local/sbin/anacron -s

The anacrontab:

SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log

1       1       cron.daily      /bin/sh /etc/daily
7       3       cron.weekly     /bin/sh /etc/weekly
28      5       cron.monthly    /bin/sh /etc/monthly

Some versions of anacron seems to understand @daily, @weekly, and @monthly (I using version 2.4.3, and its anacrontab manual does not mention those placeholders, but this one does). However, I haven't been able to find any implementations of anacron that supports using @hourly.

However, if you run anacron hourly, like I do, and if one of its jobs needs executing, then that job will be run on the hour, i.e. approximately at 08:00 rather than 08:33. But it won't be run hourly.

5

anacron is just for daily, weekly and monthly, for specific times i would recommend using cron instead.

* * * * * *
| | | | | | 
| | | | | +-- Year              (range: 1900-3000)
| | | | +---- Day of the Week   (range: 1-7, 1 standing for Monday)
| | | +------ Month of the Year (range: 1-12)
| | +-------- Day of the Month  (range: 1-31)
| +---------- Hour              (range: 0-23)
+------------ Minute            (range: 0-59)

so if you want it to run at 7am you would do, "0 7 * * * * command" this will run at 7am every day, remember that the hour is in military time. 0-23.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.