beta 296.1
The following changes have been made to a beta 296.1
* cron/crontab have been installed in the busybox
* I removed a number of useless busybox commands (saves flash)
* Start only 1 kloned prefork child (saves memory)
To update to the beta
# /etc_ro_fs/update-dev hah-beta.dbzoo.com
To get cron working after upgrading to the beta you need to do the following
# ln -s /etc_ro_fs/init.d/cron /etc/init.d/cron
# ln -s /etc_ro_fs/rc1.d/S41crond /etc/rc1.d/S41crond
To get cron running you can either reboot or start it manually.
# /etc/init.d/cron start
http://adminschoice.com/crontab-quick-reference
crontab -e Edit your crontab file, or create one if it doesnt already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
I plan that these would probably just make calls to scripts that would send xAP events.
So something like this would turn on a light at 9am every Monday and off again the same day at 5pm.
* 9 * * 1 lua /etc/cron/turnonlight.lua
* 17 * * 1 lua /etc/cron/turnofflight.lua
The LUA scripts would be as simple as
require("xap")
xap.sendShort(string.format[[
insert xap-payload here
]])
Just thoughts and some progress on getting a local scheduler working.
Brett
Here's a first stab at writing a script to use with the new cron functionality that will backup some files.
Create a file in /etc/cron and paste this into it, ie /etc/cron/hahbackup :-
#Create a backup file called /tmp/hahbackup.tar.gz
cd /
tar cvf - /etc/xap-livebox.ini /etc/passwd /etc/plugboard /etc/cron | gzip -9c > /tmp/hahbackup.tar.gz
Then chmod a+x /etc/cron/hahbackup, this makes it executable.
Edit your crontab, crontab -e, to run the script every day at 1am, * 1 * * 0-6 /etc/cron/hahbackup
To get all of the files out type :-
cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar
Or to get individual files :-
cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar <filename>
i.e. to restore your /etc/xap-livebox.ini file
cd /
gunzip /tmp/hahbackup.tar.gz
tar xvf /tmp/hahbackup.tar etc/xap-livebox.ini
I knew there'd be something, I was thinking wrong place to store the backup file or something like that though.
That's great thanks, I'll give it a go. Just using your e-mail script to get the HAH to send an e-mail when it's done :)
So here is some food for thought we can create scripts that allow some level of BSC control and their behaviour can be adjusted using parameters. This make a nice neat control interface.
We will create a scripts call "bsc" and put this in the /etc/cron directory - don't forget to chmod a+x this!
#!/usr/bin/lua
local args = require("pl.lapp") [[
Various flags and option types
-t (string) xAPBSC Target
-s (default on) xAPBSC State
-x xAPBSC Text
]]
require("xap")
if args.t == false then
print("Missing target")
os.exit()
end
xap.init("dbzoo.livebox.cron","FF123400")
cmd = string.format([[
xap-header
{
class=xAPBSC.cmd
target=%s
}
output.state.1
{
id=*
]],args.t)
if args.s then
cmd = cmd .. "state="..args.s .. "\n"
else
cmd = cmd .. "state=on\n"
end
if args.x then
cmd = cmd .. "text="..args.x.."\n"
end
cmd = cmd .. "}"
xap.sendShort(cmd)
NOW back to the crontab to crontrol some lights connected via the crontab we can do this
0 17 * * * /etc/cron/bsc -t dbzoo.livebox.controller:relay.1 -s on
0 21 * * * /etc/cron/bsc -t dbzoo.livebox.controller:relay.1 -s off
This will turn the lights on at 5pm every day and then off again at 9pm.
Again this is just me thinking out loud pipe up if you have other ideas but this is shaping up to be pretty flexible in my opinion. Albiet you need to write some code but hey that is what make is flexible. I'll work on some nice control scripts I can supply in my next beta drop.
Brett
edit: fixed crontab entry I had them turning on at 17min past the hour and off again at 21min past. Fine if you want disco lights to attract Santa.