How can I run cron every 1 second? there's only minutes option by default
Let cron start the job one time, the first time. Put the program in an infinite loop, sleep() for 1 second at the end of each loop. like this, in C:
int main( int argc, char ** argv ) {
while (1) {
// do the work
sleep(1000);
}
}
Could that work?
Cron executes stuff every minute. Use a script:
while : do sleep 1 some_command || break done
or in one line:
while : ; do sleep 1 ; some_command || break ; done
This will wait 1 second in between each execution, so if your command takes .75 seconds to run, then this script will kick it off every 1.75 seconds.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With