-1

How to know that .sh file content is really executed in crontab ?

For example : I have created .sh file and pasted a content "ping www.google.com" inside the file.

I can check in /var/logs file that the crontab is executed and details, but, how to know that the file content is really executing or not.

Rasool
  • 173
  • 2
  • 10
  • I must say I don't understand your dilemma ... you say you can check details in the logs; what else do you need to see, does your script have no tangible results? – tink Sep 27 '20 at 01:00

1 Answers1

1

make your script sh log. Something like:

log_file=/var/log/your_script/you_script.log
log_mex="bla bla"
# Other code
ping google.com
echo $log_mex $? > /var/log/your_script/you_script.log

or redirect the whole ping error message

ping google.com 2>$log_file