Cron can't do this. It only handles 1-minute resolutions. You can use sleep
to run a command a specified number of seconds after HH:MM:00, but it can't run a command every 61 seconds.
Here's a Perl script that should do what you want:
#!/usr/bin/perl
use strict;
use warnings;
my @command = @ARGV;
while (1) {
sleep 61 - time % 61;
system @command;
}
The sleep
call sleeps until the value of time()
reaches the next multiple of 61 seconds (measured since the epoch, 1970-01-01 00:00:00 UTC).
Unlike crontab
, this script won't continue running across reboots unless you do something to restart it. If you're using Vixie cron, you can use a a @reboot
cron job to restart it.
Also unlike crontab
, if the command takes longer than 61 seconds to run, the next iteration will be quietly skipped. (That might be a desirable feature).