user1597811
user1597811

Reputation: 1073

Cannot start a script

#!/bin/bash
value=$(<man.txt)
echo "$value"

if [ "$value" == "true" ]; then
    echo "startedif_manthan"
      ps -ef|grep sym |awk '{ print $2 }'|sudo  xargs kill -9;
      sleep 30;
    sudo sh /var/www/symmetric-ds-3.1.6/bin/sym --port 8082 --server;
fi

Hi There, I have this script killing a process and restart the script in some time.
It is killing the script normally but the restart script (sudo sh /var/www/symmetric-ds-3.1.6/bin/sym --port 8082 --server) is not running properly.

when I run the script manually also it is giving problems.
I don't know whether it is a shell script or not.
But when I tried to go manually to the script location and execute this command ./sym --port 8082 --server the script running normally.

Any suggestions?

Upvotes: 0

Views: 68

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 755026

Since you say it works OK when you cd to the script directory, then do that in the script:

#!/bin/bash
value=$(<man.txt)
echo "$value"

if [ "$value" == "true" ]
then
    echo "startedif_manthan"
    ps -ef|grep sym |awk '{ print $2 }'|sudo  xargs kill -9
    sleep 30
    (cd /var/www/symmetric-ds-3.1.6/bin; sudo sh ./sym --port 8082 --server)
fi

Upvotes: 1

Related Questions