[X-Unix] Cron problem solved
Marley Graham
mgraham at aquaflo.com
Fri Jun 24 12:08:11 PDT 2005
Many thanks to Norman, Eugene, Eric, David, Robert & Brian who helped
me figure out my problems with Cron and date scripting, and with
achieving a much cleaner approach.
My first problem was to get the date appended to a screencapture file
at the time of file creation by Cron. I created a script that worked
fine on the command line, but failed in Cron. The solution was to
enclose the date command in quotes for Cron.
The second problem was getting the script to run on a client computer
which I log onto with ssh. The solution to this problem was to use
root's crontab rather than the administrator's.
Several people gave very helpful suggestions for cleaning up my
scripts and consolidating the functions. It was pointed out that the
command "date +%H:M:S" would do the same thing as my "exacttime"
script, and that it could be incorporated into my screencapture
script. (Or better yet, leave out the colons in the date format to
avoid future problems).
So, here is what my screencapture script looks like:
/usr/sbin/screencapture mg$(/bin/date "+%H%M%S")
That is put into Cron using sudo crontab -u root -e:
0,30 7-16 * * 1-6 /screenpictimed
And gives an output like:
mg103000
At the end of the day, I use ps2pdf to convert the files to pdf, so I
can view them as a series of screen shots in iMovie. I created the
following script which I run to do the conversion and remove the
original files:
#!/bin/sh #psconvert
for screen in $(ls mg*)
do
ps2pdf $screen
done
rm mg*[1-9]
exit
which leaves a series of files like:
mg103000.pdf
So, thanks again for all of the suggestions. I hope the results will
be useful to someone.
Marley Graham
Aqua-Flo Supply
==============
More information about the X-Unix
mailing list