Answer the question
In order to leave comments, you need to log in
Why is the script not running in cron?
Good to everyone
The problem is that when the network card is heavily loaded, it loses the link, restarting the
service netrorking restart service helps.
Actually, changing the card did not give much result, then I made a decision, for example, ping the gateway every 5 minutes and if there is no answer, then restart the service, for this I wrote a fairly simple script, and if you work it out manually, then everything is fine, but if you put the task in crontab, then in the logs it swears at the wrong command.
#!/bin/bash
IP=8.8.8.8
RES=0
ping -q -c 2 $IP > /dev/null && RES=1
if [ $RES = 0 ];
then
ifdown enp3s0
sleep 2
ifup enp3s0
fi
In the logs:
netw.sh: line 7: ifdown: command not found
netw.sh: line 9: ifup: command not found
It's not even about quotes or syntax, it just swears at commands. What is done wrong? Why is the script not working. ubuntu server system 16.04.
PS I wanted to add more time, but something doesn't work.
Thanks to everyone who replies.
Answer the question
In order to leave comments, you need to log in
Write the full path to the executable file. Or, at the beginning of the script, define the PATH variable in which specify the path to this executable file.
Add to the beginning of the script:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question