0
Hello I wrote a simple command line script which is suppose to take my screenshot every 5 minutes.
(using ImageMagick's "import" program)
here is the script (shottr.sh):
#!/bin/sh
PTH="/home/username/images"
NM=`date +%j`_`date +"%F %k:%M"`
/usr/bin/import -window root -resize 1024 "$PTH/$NM.png" &
echo "Screenshot" | festival --tts &
this is working fine if I execute by hand i.e:
# ./shottr.sh
or
#sh shottr.sh
the cron is set like this:
*/5 * * * * /bin/sh /home/username/scripts/shottr.sh
the script itself is being executed (I hear a voice saying: "Screenshot") but the actual screenshot is not taken.
P.S: Be assured that it is NOT permission issue (I placed a simple "touch" invocation and file was created)
may be if it's run from cron...it doesn't have a "window" so it can't take a screenshot from nowhere?? If that is the case, then how can I workaround it?
Yes, the invocation from cron is most likely the issue here. – Sven – 2011-02-16T12:28:38.380
Any idea what is the workaround to this? I need to take screenshots every 5 minutes – None – 2011-02-16T12:31:00.530
what happens if just for a test you set NM=test, just to ensure its not a problem with your date command. – pablo – 2011-02-16T12:34:40.103
But it works if I invoke by hand. However I tested as you said and nothing... – None – 2011-02-16T12:40:10.487
Your date string can be simplified to:
NM=$(date "+%j_%F %k:%M")
(no need to rundate
twice). Putting the Julian day number first ruins the sortability of the filenames and you might want to consider not including a space. – Paused until further notice. – 2011-02-16T14:31:22.873Thanks Dennis, for the tip. And you are right about the naming. Fixed. – None – 2011-02-16T15:58:34.063