On 03Jun2013 10:10, Frank Murphy <frankly3d(a)gmail.com> wrote:
|
| Does this look ok,
| #######
| crontab -e # as logged in user
| */10 * * * * /home/frank/Scripts/checkazureus.sh
| #
| cat /home/frank/Scripts/checkazureus.sh
| #!/bin/bash
| if [-z "$(pgrep azureus)"]
| then
| /usr/bin/azureus
| else
| fi
| ###########
|
| azureus normally starts with xfce session,
| but it can exit dues to openjdk bug.
I am concerned that you _clearly_ have not bothered to even run
this script before posting to the list.
There are several problems:
Cron's environment is _very_ small. So you have no $DISPLAY setting
and nothing in the script sets it; azureus will not be able to
display on your screen
Test is a command, and so like any command it needs spaces around
its name:
if [ -z "$(pgrep azureus)" ]
You have a dangling "else"; syntacticly invalid. Get rid of it.
If azureus is restarted, the script never exits. Background azureus and put its output
into a log file:
/usr/bin/azureus >$HOME/azureus.out 2>&1 &
In fact, the argument to "if" is a command-list. So test pgrep directly and
invert the "if":
if pgrep -q azureus
then
echo "azureus running!"
else
echo "restarting azureus"
/usr/bin/azureus >$HOME/azureus.out 2>&1 &
fi
But next time? Test drive the script yourself from the command line;
half of this would have been found immediately.
Better than this script would be to run azureus in a loop to start with:
while :
do azureus
done
which will restart it if it quits anyway. No cron jobs playing guessing games.
Cheers,
--
Cameron Simpson <cs(a)zip.com.au>
"What do you want to reinstall today?" - Bob O`Bob
<obob(a)shell3.ba.best.com>