edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Bash script file - merging two commands

Mon Oct 26, 2015 11:32 am

Hi Guys

Sorry to trouble you but I do have a small issue with one of my bash files

I do have a crontab task which runs below task each 5 minutes to make sure my deluge server keeps running:
(deluge keeps giving me some issues that once it will upload too much of data, it keeps crashing)

Code: Select all

#!/bin/bash
#make-run.sh 
#make sure deluge is running

export DISPLAY=:0 #needed if you are running a simple gui app.
process=deluged 
makerun="service deluge restart" && "deluged"

if ps ax | grep -v grep | grep $process > /dev/null
        then
                exit
        else
        $makerun &

echo "Date: " $(date) >> /media/Intenso/Raspberry_Pi/deluge-crash.log & sendEmail -f "edmun@mailserver.com" -t "notificationemail@gmail.com" -u "Raspberry Pi Notification" -m "Deluge server and Deluge Web Access Interface has been restarted" -s "mailserver":587 -o tls=no -xu "username" -xp "password" -a "/media/Intenso/Raspberry_Pi/deluge-crash.log"
        fi 
exit
Could someone please help me out with this code and confirm if I am merging the commands together?
Somehow, I am not getting e-mails, however when I send manually (when I do paste my "sendEmail" command into ssh) the command - everything seems to be working fine.

I am kind of lost

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Bash script file - merging two commands

Mon Oct 26, 2015 12:34 pm

You probably want 2 ampersands (&&), not just 1.

Or a semicolon. Or a newline.

With the single ampersand, you are running the two commands simultaneously, which is probably not good.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

edmun
Posts: 39
Joined: Thu Jan 09, 2014 11:37 am

Re: Bash script file - merging two commands

Mon Nov 16, 2015 3:13 pm

Hi Joe

You were right. Thank you for help.
Anyway - I have resolved the problem in a different way (I hope so).
I have updated Deluge server based on the repositories for Ubuntu system.
So far looks better and program is running much more stable (does not crash so often)

Thank you for the help!

Return to “Beginners”