3

I'd like have automatic update of my gtags, but only when the system is idle.

To achieve this, I'm using iupdate to watch over the interesting parts of my source folder. But I have a problem with the "idle" part: I know that the batch command can run jobs when the load drops below 1.5 (or a configured value). But it may happen that iupdate runs batch multiple times before the job is executed which would lead to multiple gtags updates.

Of course I could create some lockfile and start batch only if it wasn't called before.

But is there some more standard method? I'm hoping for something like batch_only_once ...

1

This will do it for you:

$ cat /etc/lsb-release | grep -i desc
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
$ apt-cache show run-one
....
Description-en: run just one instance of a command and its args at a time
 This utility will run just one instance at a time of some command and
 unique set of arguments (useful for cronjobs, eg).
0

You can build a wrapper script that will first parse the atq and prune other batched jobs using atrm.

  • Unfortunately, atq doesn't include the jobname. So I'd have to fiddle with job ids… Possible, but not elegant ;) – Markus May 15 '14 at 12:45
  • That, or build horrors involving at -c (which I did in the past, and not feeling shame, cause what're you gonna do). – Felix Frank May 15 '14 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.