Minutely cron, ensuring only a single instance

Solution 1:

a better way is to use flock instead of a pidfile. check the manpage: flock(1). The advantage is that no matter how a process finishes/dies, the lock is gone with it.

Solution 2:

I would tend to agree with Warner's pid file answer. However, does the following feature of Anacron accomplish this?

-s
    Serialize execution of jobs. Anacron will not start a new job before the previous one finished. 

I haven't tested it myself, I don't find anacron's documentation thorough enough ...

If you want be particularly lazy ;-) You can just have the script exit if greping through ps output returns the process as running. But a lock/pid file is best.

Solution 3:

That's the proper solution for that approach. Typically, a pid file would be used and a pid test would be done against the process to insure it's running. If stale, the lockfile would be removed and the process would run anyway.

Any additional intelligence would typically be written in the software itself, as a daemon, as opposed to running in cron.