Steven Haryanto
and 1 contributors


norepeat - Run commands, but not repeatedly


version 0.02




Below are some examples.

This will run somecmd:

 % norepeat -- somecmd --cmdopt

This won't run command again:

 % norepeat -- somecmd --cmdopt

This will still run command because option is different:

 % norepeat -- somecmd --anotheropt

This won't repeat somecmd with any argument:

 % norepeat --key somecmd -- somecomd --cmdopt othervalue   ; # won't repeat
 % norepeat --key somecmd -- somecomd --anotheropt          ; # won't repeat

This will repeat after 24 hours:

 % norepeat --period 24h -- ...

This will repeat after change of day (equals to once daily):

 % norepeat --period daily -- ...
 % norepeat --daily -- ...

This allows twice daily:

 % norepeat -n 2 --daily -- ...


norepeat allows you to avoid repeat execution of the same command. You can customize the key (which command are considered the same, the default is the whole command), the repeat period, and some other stuffs.

It works simply by recording the keys and timestamps in a data file (defaults to ~/norepeat.dat, can be customized) after successful execution of commands. Commands might still repeat if norepeat fails to record to data file (e.g. disk is full, permission problem).

norepeat is typically used in shell startup scripts. I also use it with Dist::Zilla::Plugin::Run to run stuffs but not repeatedly.

Keywords: repeat interval, not too frequently, not more often than, at most, once daily, weekly, monthly, yearly, period, limit rate.


  • --key=STR, -k

    Set key for determining which commands are considered the same. The default is the whole command. Example:

     % norepeat -- cmd --opt1
     % norepeat -- cmd        ; # not considered the same command
     % norepeat -- cmd --opt2 ; # not considered the same command, different options
     % norepeat -- cmd2       ; # not considered the same command, obviously

    But with --key:

     % norepeat -k cmd -- cmd --opt1
     % norepeat -k cmd -- cmd        ; # considered the same command, same key
     % norepeat -k cmd -- cmd --opt2 ; # considered the same command, same key
     % norepeat -k cmd -- whatever   ; # even this is considered the same command
  • --period=STR, -p

    Set maximum period for repeat detection. The default is forever (never repeat if the same command has ever been executed). Can either be number + {sec,min,hour,day,month,year}, or {hourly,daily,monthly,yearly}.

    When comparing, local times will be used.

  • --ignore-failure

    By default, if command exits with non-zero status, it is assumed to be a failure and won't be recorded in the data file. Another invocation will be allowed to repeat. This option will disregard exit status and will still log the data file.

  • --data-file, -f

    Set filename to record execution to. Defaults to ~/norepeat.dat.

  • --num=INT, -n

    Allow (n-1) repeating during the same period. Defaults to 1, which means to not allow any repeats. 2 means allow repeat once (for a total of 2 executions).


0 on success.

0 on skipping repeated execution.

98 on failure to record to data file.

99 on command-line options error.

Otherwise exit code from command is returned.


Data file is a line-oriented text file, using labeled tab-separated value format ( Each row contains these labels: time (a timestamp either in the format of UTC ISO8601YYYY-MM-DDTHH:MM:SSZ, local ISO8601 YYYY-MM-DDTHH:MM:SS, or Unix timestamp), key (tabs and newlines will be converted to spaces).

The rows are assumed to be sorted chronologically (increasing time).


More proper date calculation.

Weekly period and n weeks interval.


Unix cron facility for periodic/scheduling of execution.

Related: modules to limit the number of program instances that can run at a single time: Proc::Govern, Sys::RunAlone.


Please visit the project's homepage at


Source repository is at


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


Steven Haryanto <>


This software is copyright (c) 2014 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.