Anyone figure out time delay code?


 

Nick S

New member
I been playing with the recipe and it doesn't seem to trigger. I am trying to do something real simple with it.

I want to start with a set point of 145 and when probe 0 see's the smoker is turned on (thermocouple on probe 0 hits a high alarm at 100. When it hits its alarm, I want to go into the time delay script and run for 45 minutes and then change the set point to 225.

So I put this in probe 0's high alarm, so when probe 0 triggers, this should run.

#!/bin/sh
# If no parameter, this is a regular alarm
if [ -z "$1" ] ; then
NOW=`date +%s`
# Set target for 45 minutes from now 2700=seconds
WHEN=$((NOW+2700))

TARGET=`date -D "%s" -d $WHEN +"%M %H %d %m"`
echo "$TARGET * /usr/share/linkmeter/alarm-all RING${al_probe}" | crontab -
else
# This is the cron callback
# Don't fire again
crontab -r

# Set Temp to 225 after 45 minutes
lmclient LMST,sp,225
fi

Doesn't seem to do anything though. I changed the time to 120 and tested it a few times. Never changes the set point to 225.
 
Looks like the init script for cron aborts starting the daemon if there's no crontab on startup. I'd add a line after you set the crontab - to make sure it is running:
Code:
...
  echo "$TARGET * /usr/share/linkmeter/alarm-all RING${al_probe}" | crontab -
  [ -z "$(pidof crond)" ] && /etc/init.d/cron start
else
...
 

 

Back
Top