0

I have some automated python files that run continuously at a certain time and I have added them to a bash script to run them at once. Individually the python files' automation work in testing, and the bash script worked on a unix server, some issues meant I had to start running the script from a local Mac book and now the automation has stopped working.

The bash script still works as I see the results of the python files running when I start it, but the next day the automation hasn't kicked in.

The code to run the python file is:

nohup command >/dev/null 2>&1 python3 "path/to/script/pythonScript.py" &

This code as I said worked on a unix server for running the pythons, letting me close the connection and the python code doing it's automation.

I've tried adjusting the Mac's setting to not sleep, turned off needing to log in for wake up, automator attached to a daily calendar event, caffeinate -i and caffeinated -s and nothing has worked so far. My next attempt will be caffeinate -u to simulate user activity but after that I'm out of options.

The likelihood soon is I'll start running this from a Raspberry Pi so I'm trying to find a solution by the time I have to move the script over.

Omega001
  • 31
  • 1
  • 2
    What is `nohup command ...` ? Surely you want `nohup python3 script.py &` – Mark Setchell Aug 26 '22 at 09:27
  • In my research that command stops nohup from saving output to a file. https://stackoverflow.com/questions/10408816/how-do-i-use-the-nohup-command-without-getting-nohup-out – Omega001 Aug 30 '22 at 09:23
  • I don't know if this would come into play for you, but I have an "Energy Star" monitor for which no amount of tinkering can bypass built-in hibernation without keyboard activity. Having said that, there must be a setting to prevent hibernation/sleep/etc. if user processes are actively taking up CPU cycles, regardless of whether that is foreground or background. For some, ensuring background is not ignored can be a challenge. – Eric Marceau Sep 18 '22 at 19:34
  • What Mark was alluding to, the proper command form should be nohup python3 "path/to/script/pythonScript.py" >/dev/null 2>&1 & – Eric Marceau Sep 18 '22 at 19:39

0 Answers0