Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 05-18-2014, 10:07 AM   #1
LQ Newbie
Registered: Dec 2005
Location: Denmark, Copenhagen
Distribution: Ubuntu Ultimate v.6
Posts: 10

Rep: Reputation: 0
How to make this script to a service.

I am making a simple visualization tool, that shows the state of some equipment using a few lamps connected to a small computer through a usb relaycard.

The computer runs Debian and the relaycard is a "DenkoviRelayModule".

The basic doing the checking and visualization is basically a loop that runs each 5 seconds. I have gotten the script to function, and can run it.

It would, however, be much better if i could run it in a service-like fashion so i would not need to ssh to the computer each time to start the script. Also, I would like a neat way to run a script whenever the computer shuts down so that the relay state reset.

Having never done any services, I would really like some pointers on how to do it, good practives etc... Note that the script need to run with root permission.

Any hints would be welcome

.... The script in simplified version looks like this.


#Denkov relaycard needs the ftdi and serial module to be unloaded to function.
#This must be done using root credentials.

rmmod ftdi_sio
rmmod usbserial

#Assuming only one relay is attatched, get its serial.
#All java commands accessing the card must be run as root.
DENKOVI_SERIAL=$(java -jar $DENKOVI_JAR list | awk '{print $1}');
echo Attatched relayboard has serialnumber : $DENKOVI_SERIAL

#simplified version, in actual script servers are checked before setting relay state.

while true; do
java -jar $DENKOVI_JAR $DENKOVI_SERIAL 4 turn 0000
Old 05-18-2014, 10:14 AM   #2
LQ Guru
Registered: May 2005
Location: boston, usa
Distribution: fedora-30
Posts: 5,289

Rep: Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916Reputation: 916
iirc, daemonizing or turning a process into a service implies periodically checking for a status to change and then act appropriately (e.g.: httpd).

what you seem to want is a method of auto-starting your script Ipoh reboot ?

Last edited by schneidz; 05-18-2014 at 10:29 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i make a scripts as service jayakumar01 Linux - Server 2 09-10-2012 07:51 AM
How to make TCP server a daemon / service much like a dhcpd service? rajat Linux - Networking 1 05-22-2007 01:29 AM
make service dansguardian baambooli Slackware 3 08-28-2006 11:02 AM
How do I make something a system service? sloik2000 Linux - Software 3 03-25-2005 03:16 PM
How to make service always start? Arodef Linux - Software 4 01-05-2005 06:25 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration