Go Down

Topic: Any experience with run levels in linux and daemons? (Read 793 times) previous topic - next topic


Hi all,

Im having some problems using serial communication to my arduino from a daemon Ive written in perl running from init.d on a ubuntu box.

This is a headless server running the cctv system zoneminder.
The arduino is going in a switch box connected to the server by usb cable so the Scout leaders at the hut the cctv is covering can turn it on and off without having to touch a keyboard.

The daemon communicates over serial/usb to the arduino that has a key switch and a couple of status led's.
Ive set the daemon running under level 3 and above in the init.d bash script but im getting no response from the arduino script over serial.

If I run the perl script/daemon from the command line it works perfectly.
But not if I start it as a service via "service zoneswitch start".
So its something to do with init.d and the permissions/runlevels the perlscript/daemon is running under.

So Im wondering if anyone has any experience with daemons under linux, run levels and serial/usb and maybe can give me a pointer or two.
I can post the code but its a bit on the long side so Ill wait till someone requests it if it will be a help.




Have you tried executing the script in this file?
It is executed after all multiuser startups.


I could give it a try, but I'd prefer to have it run from inet.d.
Ive posted on perl monks as well.
Ill keep plugging away.



Please clarify what works and what doesn't. The actual perl script/daemon works when you run it in a terminal? The init script doesn't work when you try to start it using "service zoneswitch start", but what happens if you try to run the init script directly,  i.e., "/etc/init.d/zoneswitch start"? Do you get any error messages or does it fail silently? You could also post the init script and the perl code here.


Thanks for looking.

Good point running the bash init script directly, "/etc/init.d/zoneswitch start".
Dont know why I hadnt thought of that. I might get more of an idea of whats happening.

I can run the perl script directly, everything works as expected.

Run it through "service zoneswitch start". Daemon starts and stays started. I get all the debug info through syslog as expected but nothing goes over the serial/usb link to the arduino.

Ill give "/etc/init.d/zoneswitch start" a go and see what I get then. Maybe Ill see some errors or warnings this way.

Ive posted all the code on perl monks so rather than cluttering here up, it can be seen here:http://www.perlmonks.org/?node_id=973357


Go Up