简体   繁体   中英

shell script not running the other script inside it

#!/bin/bash
value=$(</var/www/sym_monitor/man.txt)


if [ "$value" == "true" ]; then

     ps -ef|grep sym |grep -v grep |awk '{ print $2 }'|sudo  xargs kill -9;
cd /var/www/symmetric-ds-3.1.6/bin;
sleep 30;

(sudo ./sym --port 8082 --server);

fi

I'm trying to run the above script every 10 mins using cron. While running it under root manually the script is doing fine but when I try to run the script inside cron it is executing the (ps -ef|grep sym |grep -v grep |awk '{ print $2 }'|sudo xargs kill -9;) and it is not executing the script (sudo ./sym --port 8082 --server) and it is not giving any error. Can anybody suggest me any idea?

Please check if crontab is also running in Bash. If not then you might have have to change your shell.

Also when you are running the script manually, ./sym is a location pertaining to your shell. It might not be as per cron. Please use full path to execute ./sym.

sudo may require a password, thus blocking this command.

Removing sudo would solve the problem, I guess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM