0

I'm on Freebsd9.2.(I have to use this operating system) I want to run multiple scripts with at command but I want to ignore running a script in a same time.

For example: I have 3 script files: 1.sh, 2.sh, 3.sh

I have a job to execute 1.sh at today 16:20, when I run the at command with the same time and script, the number of the jobs in /var/at/jobs changed to 2 jobs. I want to ignore this, but the script 2.sh can run with thw same time. Do you have any idea what should I do?

hlovdal
  • 23,353
  • 10
  • 78
  • 148
F.M
  • 359
  • 2
  • 6
  • 17

1 Answers1

0

I don't know if I understood correctly the problem, but maybe the command lockf could help.

For example try this in one terminal:

$ lockf -t 0 /tmp/a.lock sleep 5

In another terminal run:

$ lockf -t 0 /tmp/a.lock echo "sleep finished"

In this example until the command sleep 5 doesn't exit, if you try to run another command you will get something like:

lockf: /tmp/a.lock: already locked

A cron example:

15 4 * * * lockf -t 0 /tmp/poudriere.lock /usr/local/etc/poudriere.d/cron 12amd64 default

This prevents running the script/app if the lock exists, so probably you can get an idea of how you could use it with at

nbari
  • 20,729
  • 5
  • 51
  • 86