I found that it can not ping from the shell script launched by cron.
I wrote shell script like this:
#!/bin/bash
ping localhost
echo "Exit status: $?" >> /tmp/ping.log
And I configured crontab so that this script is executed at every minutes.
crontab -e
# I wrote * * * * * /path/to/the/script
In some minutes, I checked the file /tmp/ping.log
. According to the log, the status code of ping was 127, indicating it failed.
When I execute ping in usual interactive shell by hand, It succeeds.
Why does it fail from cron ?
Asked by hotoku
(33 rep)
Dec 21, 2024, 09:49 AM
Last activity: Dec 27, 2024, 09:11 PM
Last activity: Dec 27, 2024, 09:11 PM