user1597811
user1597811

Reputation: 1073

two crons not running simultaniously?

MAILTO=""
*/10 * * * *  /bin/bash /var/www/sym_monitor/sym_start.sh > /var/www/migrate/root_start.txt 2>&1
*/10 * * * *  /bin/bash /var/www/sym_monitor/stop.sh > /var/www/migrate/root_stop.txt 2>&1

Both these are jobs inside cron running at 10 min interval @17:30 second one starting and 1735 first one starting avoiding the killing of first job by second before it actually started.

First script consist of the following code

#!/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;

fi

Second script consists of the following code.

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

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

sleep 30;
cd /var/www/symmetric-ds-3.1.6/bin;
(sudo ./sym --port 8082 --server);

fi

The problem is when I run both the scripts unfortunately sym_start.sh is not executing. But when I remove the stop.sh and manually run the stop script then the only script in the cron is executing properly. why thus this happen? any idea?

Upvotes: 0

Views: 50

Answers (1)

Pradheep
Pradheep

Reputation: 3819

can you try changing

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

to its absolute path

(sudo /var/www/symmetric-ds-3.1.6/bin/sym --port 8082 --server);

I think the path is not getting changed in the shell

Upvotes: 2

Related Questions