at and cron annoyingly different
D. Hugh Redelmeier
hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Thu Nov 17 03:05:08 UTC 2011
I want to run a cron job in a particular directory. Running the
crontab(1) command from that directory isn't enough: the script will
run with ~ as the current working directory.
So I wrote the script file for cron in the directory of interest and
told cron to run it. In that script, I used
cd `dirname "$0"
So the script would change the directory to the one containing the
script. That worked well.
For unrelated reasons, the script didn't work, so I fixed it up and
tried to run it using at(1).
- at(1) does remember the working directory in which it was run and it
runs the script file with that current working directory. So my
tricky cd command wasn't needed for at.
- at(1) runs the script with $0 set to /bin/bash so my cd is actually
very wrong for at. I don't want /bin as the working directory.
All this I figured out by debugging. Since the runs were not frequent
(once a day) debugging was stretched out.
Surely these related commands could converge so that differences
between scripts could be minimized.
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list