Hi!

I’ve a cronjob that I don’t want to be concurrent but it needs to leave a long-running process after it does it’s job that I set up with a nohup command.

The deal is that once the script has setup the lock doesn’t get released so any further calls to the script just get ignored.

Is there a better alternative/flag I’d use? I couldn’t discern much from the flock or nohup man pages.

Solved: With bit more fiddling found the - u flag on the flock man page. You can unlock yourself at the very end of the script.

  • Frid0lin@feddit.org
    link
    fedilink
    Deutsch
    arrow-up
    2
    ·
    25 days ago

    Could you just save the pid of that cronjob in a file? (Assuming this cronjob calls bash script). Before the next run of the cronjob check if that process with that pid is still running? Hoping, I understand your problem correctly. You do not want to run the cronjob again until the first run finishes?

    • Gonzako@lemmy.worldOP
      link
      fedilink
      arrow-up
      2
      ·
      25 days ago

      Flock does this functionality, the deal is that it waited for the long-running process to end so it wouldn’t release the lock after the script was done. Adding a line manually releasing it fixed it.

      It’s an auto-update script, you don’t wanna start a new update while one is underway.