0 votes
93 views
in Linux by
How can I configure a cron job to run every 2 minutes and 30 seconds in Linux?

1 Answer

0 votes
by

Unfortunately, it is not possible to run a cron job every 2 minutes and 30 seconds as the cron daemon only supports scheduling at the level of minutes.

One way to achieve this would be to schedule a cron job to run every 2 minutes, and then within the script that the cron job runs, include additional logic to only execute the desired task every 2 minutes and 30 seconds.

For example, you can use the following cron expression to run a script every 2 minutes:

*/2 * * * * /path/to/script.sh

And then within the script, you can use the sleep command to pause the script for 30 seconds before executing the task.

#!/bin/bash

# wait for 30 seconds

sleep 30s

# execute task

command-to-be-executed

This way you can run a task every 2 minutes and 30 seconds.

...