Search code examples
bashmacoscron

How to get notified when crontab fails


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


Solution

  • 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