Search code examples
python-3.xpython-2.7schedulelinux-mintpython-webbrowser

Python script stops to execute on startup after some time


More than a month ago I've added this script to my startup applications. It worked just like it should, every single time.

Now, for some reason, it's not working every single time (primarily it's not working every single time in the morning, there are different variations now).

I've changed the interpreter, shortened paths - it didn't help. And when nothing happens, after (and before) typing a command to find all working python processes

ps -fA | grep python

this process is there.

I'm on Linux Mint 18.3 MATE. Thanks.

#! /usr/bin/python3

"""My Alarms."""

import schedule
import time
import webbrowser
import subprocess


def breakfast():
    """Breakfast reminder."""
    subprocess.Popen(['notify-send', 'TIME TO EAT BREAKFAST'])
    webbrowser.open('/path_to/carbon.ogg')


def dinner():
    """Dinner reminder."""
    subprocess.Popen(['notify-send', 'TIME TO MAKE A DINNER'])
    webbrowser.open('/path_to/carbon.ogg')


def shut_down():
    """Shut Down (Laptop) reminder."""
    subprocess.Popen(['notify-send', 'TIME TO SHUT DOWN THE PC'])
    webbrowser.open('/path_to/carbon.ogg')


schedule.every().day.at("07:35").do(breakfast)
schedule.every().day.at("17:10").do(dinner)
schedule.every().day.at("21:00").do(shut_down)


while True:
    schedule.run_pending()
    time.sleep(1)

Solution

  • Turns out, I haven't met requirements for the schedule module. Some of these modules were updated, some were missing. Now it's working like it used to be. Case closed.