Question

I have a Cron Job scheduled to execute a command a few times a day. There are cases where the cron job isn't needed but will automatically run. If that happens the following error message shows:

PM2 [ERROR] Script already launched, add -f option to force re execution

Note: The Cron Job runs PM2 in reference to a script.

Is there any negative effect to having the cron job run even if the script is already running?

Please provided detailed information or references. Not just your opinion please.

Était-ce utile?

La solution 2

Not sure what detailed information or references there could be for a situation like this. It's not like someone commissions a study to look at this.

Assuming your command is intelligent enough to only allow one execution at a time (which appears to be the case judging by the error message you posted) then the only ill effect is a few CPU clock cycles (I think).

Autres conseils

Avoid erroneous error messages by writing a wrapper script that is run from cron instead. Inside the wrapper script, only run your job if it is not already running by querying the process table.

Assuming ksh, here's a snippet (I'm a tad rusty so syntax may need to be tweaked):

# Running will be non-zero if no match found
running=$(ps|grep MY_PROGRAM)
if [[ "$running" -gt 0 ]]; then
  # run your program
else
  # log its already running
fi
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top