Answer the question
In order to leave comments, you need to log in
Why is the sh script not running?
Greetings! I can't understand why the sh script is not executed...
There is a script in crontab with parameters:
*/1 * * * * /root/astrachecker.sh > checkerlogs.log
nc -vz 127.0.0.1 8080
if [ $? -eq 0 ]; then
echo OK
else
echo FAIL
perl pushmsg.pl
/usr/bin/astra --relay -l ip -p 8080 --log /var/log/astra/astra.log
fi
May 25 18:32:01 d1 CRON[1443]: (root) CMD (/root/astrachecker.sh > checkerlogs.log)
Answer the question
In order to leave comments, you need to log in
Well, first.
Shebang is a must! For a long time already, all scripts without a shebang may well be executed in the wrong place, not in the right way, or not executed at all.
Second.
PATH at the beginning of the script is required . Do not rely on defaults, set somewhere by something - they may turn out to be completely different from what you think.
Third.
For safety net, each command needs to specify the path. That is, not "nc", but "/usr/bin/nc" (well, or where you have it)
*/1 * * * * /root/astrachecker.sh >& checkerlogs.log
Problems with cron always rested on:
1) The need to write the full path to programs / scripts, because how else can the system understand what to run from where
2) PATH, try to write the full path of the pearl in PATH:
On the command line:
PATH=$PATH: /usr/bin/perl ##(this is just an example, I don't know where your perl is)
export PATH
PS
View the path where perl is located:
which perl
PS2:
And yes, does everything work correctly through the command line?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question