How would I get a cron job to run every 72 minutes? Or some not so pretty number like that?
相关问题
- Why does this bash script work at console but fail
- Create scheduled task using Task Scheduler Managed
- Using task scheduler for running java jar (from ba
- cPanel cron job, no input file specified?
- Why is a valid path with a tilde not expanding in
相关文章
- Schedule Rails Task to run at a certain time
- crontab command not found in my git-bash for windo
- Cron scheduler of python script using notify-send
- Spring scheduled tasks not firing
- Show failure for SQL 2005 Job that executes Powers
- crontab issue when using exec php script?
- Any way to run Firefox with GreaseMonkey scripts w
- Chrome 73 stop supporting headless mode in backgro
Use at (man at). Have your app or startup script calculate a startup time 72 minutes in the future and schedule itself to run again before it starts working.
Available on windows xp and vista too.
Here's an example for gnu/linux: at -f command.sh now + 72 minutes
Since
cron
runs jobs time-based, not interval-based, there's no blindingly simple way to do it. However, although it's a bit of a hack, you can set up multiple lines incrontab
until you find the common denominator. Since you want a job to run every 72 minutes, it must execute at the following times:As you can see, the pattern repeats every 6 hours with 5 jobs. So, you will have 5 lines in your
crontab
:The other option, of course, is to create a wrapper daemon or shell script that executes and sleeps for the desired time until stopped.
Uh I know this is long overdue, but I was looking at some scheduling issues and saw this question.
Just do this in your crontab
*/72 * * * * /home/script.sh
You could always take the approach of triggering cron every minute, and having your script exit out immediately if it's been run more recently than 72 minutes ago.
You cannot directly do this from cron/crontab.
Cron jobs are run on a specific schedule, not on a specific interval.
One alternative would be to work out a schedule that approximated your "every 72 minutes" by running at midnight, 1:12, 2:24, 3:36, ..., and stretching it out to approximate hitting up at midnight. Your crontab file could specify all of these times as times to execute.
Another alternative would be to have a separate application handle the scheduling, and fire your application.
You'll need to set exactly 20 tasks for this - i.e. set one at 00:00, next one at 01:12, next one at 02:24, etc.
20 iterations make a full day.
Unfortunately, this is the only way to do it, as cron tasks are set up in a fixed schedule beforehand instead of being run, say, "after X minutes the last task was executed".