1

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)
  • If you are okay with not using python for this job, As you are anyway running bash commands there, Try [cron](https://www.howtogeek.com/101288/how-to-schedule-tasks-on-linux-an-introduction-to-crontab-files/). It's made just for this utility. – Udayraj Deshmukh Feb 26 '18 at 21:02
  • Maybe I'll try cron. But still, why did that happen with a python script in the first place? Confused. – Alexander Lavrenko Feb 27 '18 at 05:28
  • I can't answer that. Try to write something with timestamps to a log file to help debug it. Make sure to open it in append mode like `open("scriptLog.txt","a") as f:` – Udayraj Deshmukh Feb 27 '18 at 05:53
  • I'll do. Thank you for everything. – Alexander Lavrenko Feb 27 '18 at 06:04

1 Answers1

0

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.