Mac automator to rerun a python script if first attempt failed

automatoremailpython

I wrote a python script to automatically send emails and used automator to run it by run shell:

/usr/local/bin/python /Users/austin/PycharmProjects/assignments/assignments.py

This assignments.py prints 'successfully sent the mail' after emails are sent

I'm wondering if there is a way to let automator rerun this script if it did not receive the 'successfully sent the mail'

Best Answer

It really depends - is there any "pause" or do you want to continually keep sending emails? This sounds a bit SPAM-y?

If you have created a 'process' that does some checks and then if there is work to be performed - it does its work and when finished goes back to "sleep". This sounds more like a daemon task loop.

You can leverage launchctl. It will keep a daemon/process running indefinitely. I'd suggest you install your script in your user space not the system. The only difference is it will not start up until you log into your Mac.

Related Question