The min time for a crond job is 1 minute, is there any package that has the same use as crontab and can set a second job
Asked
Active
Viewed 30 times
0
-
Seems none those kinds of tools exists, I will just modify crond for my own version, thanks, everyone. – forgaoqiang Oct 12 '21 at 07:36
2 Answers
0
You can do it with SystemD on most modern Linux distributions. Please see this topic and the SystemD-specific answer in it: Running a cron every 30 seconds

Gregory Morozov
- 11
- 1
- 2
-
Thanks for the answer, I know that way, sleep with a delay, but does there any package that can do the second job itself? – forgaoqiang Jul 29 '21 at 02:54
0
Although there is no "real" way to run a job less than a minute with cron
... I have used this work-around for years with no issues. Say you wanted to run the cron every 30 secs. You set 2 processes to run every minute .. And set one to sleep
for 30 secs. IE
* * * * * sh /path/to/script/shell.sh
* * * * * ( sleep 30; sh /path/to/script/shell.sh )
Effectively running the cron every 30 seconds.
Conversely if you wanted it to run every 20 seconds:
* * * * * sh /path/to/script/shell.sh
* * * * * ( sleep 20; sh /path/to/script/shell.sh )
* * * * * ( sleep 40; sh /path/to/script/shell.sh )
NOTE this is a work-around!

Zak
- 6,976
- 2
- 26
- 48
-
Thanks, I knows that trick, but does there any package has the ability to do the second job itself – forgaoqiang Jul 29 '21 at 02:53
-
-
I check it in Google and GitHub, didn't found one, is that a great idea to just rewrite crond and publish a new package to do that job? – forgaoqiang Jul 30 '21 at 06:37