#!/bin/bash
JOB_ID=$(echo kill $$ | at now + 3min | awk '/^job/ {print $2}')
cd /foo/bar/
./baz
atrm $JOB_ID
If it doesn't get killed by at, it removes the kill job from the queue.
Makeshifts last the longest. | [reply] [d/l] |
| [reply] |
| [reply] |
I thought of that, but since my task was already _starting_ from a cronjob, having it set up an at job to kill itself later looked even wierder to me than this Until module does :)
You're right, though, it's another way to do it.
(Edit: Aha, NOW I remember why I did this! If you set up an at job to kill process nnnnn, there's no guarantee your script won't die for some other reason before the at job runs, so that pid might be reused, which means you might kill the wrong thing, if the pid belongs to you or you're root. This way, process nnnn is a child of Until, so it WILL still be around, even if its defunct.... I don't have the root issue, my script runs as a normal user.)
--
Mike
| [reply] |