Page 1 of 1


Posted: Sat May 04, 2013 1:09 pm
by NDLBoard
Good evening,

I am using my phidget SBC to manage the heating and the double-flow ventilation system of my house (in France - sorry for my not very accurate English).
I am very happy with my SBC, all my programs are written in Java, they are .jar launched at the booting of the SBC.
There are 3 projects:
- one managing the heating (towards the 8 8 8 phidget of the SBC)
- one managing the ventilation (towards one more 8 8 8 phidgets connected to the SBC via USB)
- one that allow me to drive the system from anywhere and that send me an email in case of any misfunction (towards the wire internet connection of the SBC)
The two first programs are very stable, they have been running for months without any problem (at the end I noticed the SBC was very slow when connecting with the web interface, so I rebooted it and it was OK for another couple of months)
The last program is crashing after a non determinated amount of time (between 5 minuts and a week), pheraps because this program is too heavy, peraphs due to a memory leak, I did not managed to fix it.

That is why I am trying to launch it via crontab each hour, and to make it die after one hour of work (if it has not already crashed before by itself....)

I have tried a lot of crontab commands, none is working.

My program is located from sbc root:

The crontab file I edited is the one located:

In which I added the line:
00 * * * * root java -jar /usr/userapps/DataLink/DataLink.jar

Will really appreciate any help!
Best regards

Re: Crontab

Posted: Mon May 06, 2013 9:35 am
by Patrick
I usually create a shell script for cron to run, and then start my program from there. I'm not sure how happy cron is with command line arguments like you have. Also, the PATH may not be set. 1st try specifying the full path to java, otherwise, create a shell script.

Also, you will probably want to verify that the program isn't running before starting another instance - something else you can do in a shell script.


Re: Crontab

Posted: Mon May 06, 2013 10:35 am
by Patrick
Also, look into supervise from daemontools.


Re: Crontab

Posted: Tue May 07, 2013 3:59 pm
by NDLBoard
Thanks Patrick for your answer,

I have tried to do what you suggested to me,
but I am not familiar with shell scripts and I did not managed to launch my .jar

I added to /etc/crontab the line:
00 * * * * root /usr/userapps/DataLink/

I added the file in my project directory, this file contains:
/usr/lib/jvm/default-java/jre/bin/java -jar DataLink.jar

(NB: I modified my program to make it die after 1 hour work to avoid 2 instances to execute at the same time, I will study your suggestion of supervise later on)

The System Log show a crontab exit code 126: Command cannot execute
I think it may be due to a syntax problem but I do not manage to fix it

Thank you for your help!

Re: Crontab

Posted: Tue May 07, 2013 4:49 pm
by Patrick
ok, other then this, you will need to make your script executable with 'chmod 755'

You also should deamonize the java program with &, unless it daemonizes itself:

Code: Select all

/usr/lib/jvm/default-java/jre/bin/java -jar DataLink.jar &


Re: Crontab

Posted: Tue May 21, 2013 10:28 pm
by NDLBoard
Thank you Patrick for your help,

I did the chmod as you suggested so as to compil the shell script,
it worked: there is no more system log error code after the crontab execution,

unfortunately, my programm is not launched...
my shell script is located in my project directory and contains:

/usr/lib/jvm/default-java/jre/bin/java -jar DataLink.jar &

I guess that crontab is properly launching the script (as the error code disappeared),
I probably have a wrong classpath in my shell script,
I have tried a lot of possibilities, but with no result,

I you have any idea...