Results 1 to 4 of 4
Hello
I'll describe my problem I have my own server running which sometimes "crashes", so I thought I could check every minute and if its down - start it.
I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-31-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 3
Crontab - running a scrtipt
Hello
I'll describe my problem I have my own server running which sometimes "crashes", so I thought I could check every minute and if its down - start it.
I wrote a script
Script is working If I run it manually, but if I run it through Cron.Code:#!/bin/bash if ! lsof | grep 6011 then /home/path/server config.xml fi exit 0
its not workingCode:crontab -e 0-59 * * * * /home/path/server_enabler.sh
Cron itself is good, because i wrote simple script creating a file, and its ok. I tried to add & at the end to run it in the BG, but it didn't help. What could be the problem ?
- 03-31-2011 #2
The issue is most likely environment.
cron has a different one that your user.
So you need to find out, what $PATH, etc your server needs.
Other than that:
It would be possible to implement the restart functionality via /etc/inittab.
Other other than that
The best option is to find out why this server crashes and fix that.You must always face the curtain with a bow.
- 03-31-2011 #3Just Joined!
- Join Date
- Mar 2011
- Posts
- 3
I copied my environment
then found on he internet how to run cron, I triedCode:env > .profile
andCode:0-59 * * * * /usr/bin/bash -c '. /home/myuser/.profile && /home/path/myscript.sh'
But no response from the Cron (wish there was a error log or something)Code:0-59 * * * * [ -f /home/myuser/.profile ] && . /home/jimmy/.profile && /home/jimmy/cha/scripts/cekpderr
EDIT:
I simplified script to
and still nothing.Code:#!/bin/bash /home/path/server config.xml exit 0
Last edited by Juzbrig; 03-31-2011 at 11:43 AM.
- 04-01-2011 #4Just Joined!
- Join Date
- Mar 2011
- Posts
- 3
It works !
I modified the script :
Code:if ! lsof | grep 6011 then cd /home/sciezka/ ./server konfig.xml fi
Last edited by Juzbrig; 04-01-2011 at 11:20 AM.


Reply With Quote
