So I have a collection of scripts which are used to control my reciever and tv power during certain events like boot, screensaver, and remote control. One of these is executed during login but the thing is maybe I don't want it to run the script when the machine is scheduled to power up. I have the logic to ignore events if blanked = 0 during execution of startup apps, hence it wont send ir during boot or shutdown. How can I accomplish this through the use of cron? I choose cron because those events happen before startup applications. Cron is awesome but as far as I understand I can only run at boot or on a schedule not both. I need to script the time variable but I'm not sure how.
syson.sh (called during login as a startup app and screen state change)
#!/bin/sh
cd /home/gilson585/
blanked=`cat blanked`
if [ $blanked -eq 0 ] ; then
blanked=1;echo $blanked > blanked
else
irsend SEND_ONCE VR4085DF KEY_POWER;irsend SEND_ONCE Kenwood_RC-R0813 power;blanked=0;echo $blanked > blanked
sleep 1
irsend SEND_ONCE Kenwood_RC-R0813 cd/dvd
fi
sysoff.sh (called during shutdown as part of lirc init.d script and screen state change)
#!/bin/sh
cd /home/gilson585/
blanked=`cat blanked`
if [ $blanked -eq 0 ] ; then
irsend SEND_ONCE Kenwood_RC-R0813 power;irsend SEND_ONCE VR4085DF KEY_POWER;blanked=1;echo $blanked > blanked
fi
xscreensaver.sh (screensaver watchdog, called during login)
#!/bin/bash
cd /home/gilson585/
xscreensaver-command -watch|
while read STATUS; do
case "$STATUS" in
BLANK*)
/home/gilson585/sysoff.sh;blanked=1;echo $blanked > blanked
;;
UNBLANK*)
/home/gilson585/syson.sh;blanked=0;echo $blanked > blanked
;;
esac
done
Ah. At the least, you can use two scripts for now. The time setting is a list of weeks/hours/minutes/seconds/etc. You set it up with parameters like
This would execute something on minute 42 of each hour. This page has an explanation that I would basically be regurgitating: http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/
There's also scripts like
Which will do awesomestuff.sh at 9:42, 12:42, and 15:42