Comments on: How To Run a Cron Job Every 30 Seconds in Linux https://www.tecmint.com/run-cronjob-every-x-seconds/ Tecmint - Linux Howtos, Tutorials, Guides, News, Tips and Tricks. Thu, 13 Jul 2023 15:58:30 +0000 hourly 1 By: Onan the Barbarian https://www.tecmint.com/run-cronjob-every-x-seconds/comment-page-1/#comment-1941871 Wed, 04 Jan 2023 09:02:48 +0000 https://www.tecmint.com/?p=48957#comment-1941871 In reply to Aaron Kili.

That doesn’t work. The first example runs a job at second 0 and another at second 17 of every minute. The second run is at second 0 and 30.

To really run a job every 77 seconds, you need to run it:

– at second 0 of the first minute.
– at the second 17 of the second minute.
– at second 34 of the third minute.
– at second 51 of the fourth minute.
– at second 8 of the sixth minute.

and so on. The cycle repeats every 77 minutes.

]]>
By: Aaron Kili https://www.tecmint.com/run-cronjob-every-x-seconds/comment-page-1/#comment-1933828 Wed, 21 Dec 2022 10:50:33 +0000 https://www.tecmint.com/?p=48957#comment-1933828 In reply to dragonmouth.

@dragonmouth and @Biapy

From the man page of the sleep command, the sleep command pauses for x number of seconds and the suffix is s for seconds, the default or m for minutes.

To schedule a job for 77 seconds, simply add these entries in the crontab:

* * * * * date>> /tmp/date.log
* * * * * sleep 77; date>> /tmp/date.log

For 90 seconds, use this:

* * * * * date>> /tmp/date.log
* * * * * sleep 90; date>> /tmp/date.log
]]>
By: Aaron Kili https://www.tecmint.com/run-cronjob-every-x-seconds/comment-page-1/#comment-1933817 Wed, 21 Dec 2022 10:04:28 +0000 https://www.tecmint.com/?p=48957#comment-1933817 In reply to Biapy.

@Biapy

I will give systemd a try to implement a solution to the above problem.

Many thanks for sharing your thoughts about this post.

]]>
By: Biapy https://www.tecmint.com/run-cronjob-every-x-seconds/comment-page-1/#comment-1933051 Mon, 19 Dec 2022 07:57:43 +0000 https://www.tecmint.com/?p=48957#comment-1933051 In reply to dragonmouth.

Hi,

This method can be used but is really not recommended. The trick is to use a number of minutes that is a direct multiple of the number of seconds wanted. E.g. for the 90s, setup the cron task to be launched every 3 minutes (e.g. 90s * 2):

*/3 * * * * date>> /tmp/date.log
*/3 * * * * sleep 90; date>> /tmp/date.log
]]>
By: Biapy https://www.tecmint.com/run-cronjob-every-x-seconds/comment-page-1/#comment-1933048 Mon, 19 Dec 2022 07:52:17 +0000 https://www.tecmint.com/?p=48957#comment-1933048 Hi,

In my opinion, if a cronjob is needed to run so often, it is either time to daemonize it using systemd, and/or implement an event-driven task (e.g. use inotifywait to watch for filesystem changes).

Either way, thank you for your work on this blog.

]]>