Reputation: 67
Trying to detect if my crontab job fails and if so I would want it to notify me but I could not find any information on that but the following from the old crontab.guru. What does the following mean?
&& curl -sm 30 k.wdt.io/<email-address>/<cronjob-name>?c=
Is there a good way to create a script in case crontab fails?
Using Mac OS
Upvotes: 2
Views: 1122
Reputation: 45112
wdt.io was a cron job monitoring service. It was discontinued a while back.
The idea with the && curl
syntax is to run a HTTP request every time after your cron job completes successfully (with an exit status 0).
&&
will not be executedEither way, the idea with wdt.io was to check if it is receiving HTTP requests on a defined schedule. As soon as a request does not arrive on time, wdt.io would detect that and notify you.
This is a form of Dead Man's Switch and there is a number of SaaS offering this service. You can search the web for "cron job monitoring" and you will find them no problem :-)
Upvotes: 0
Reputation:
crontab -e
[email protected]
* * * * * echo 'hi' >> hi.txt
please check if you have a MTA like this :
netstat -tlnp |grep :25
or using sudo
sudo netstat -tlnp |grep :25
and you should get a row like
root@linux:~# netstat -tlnp |grep :25
tcp 0 0 192.168.1.100:25 0.0.0.0:* LISTEN 1322/master
if you do not get that then you install ssmtp
sudo apt install ssmtp
sudo dpkg-reconfigure ssmtp
Upvotes: 1