It's convenient to be able to program the server to execute some tasks without our manually initiating them. One way to do this is by using cron, a daemon that runs on your system.
If you've written a program that can send you a text, let's have the server automatically run that program at 7am every morning. We'll have the server send us a "Wake up!" text.
$ crontab -e... and hit [Enter]. You'll be presented with some text on the screen which may not make much sense right away. That's okay. We're going to add an entry to this file that will cause the webpage to be opened at a specific time every day.
59 06 * * 1-5 /usr/bin/python3 /home/ubuntu/Documents/pythonGmail/wakeup_text.pyNote that we're using the full path to indicate which Python we want to use and where exactly the script is located. This is because cron may run as a different user with different defaults, so specifying absolute paths rather than relative paths will avoid any potential difficulties.
crontab program runs in the background on your computer, and checks every minute or so to see if it should be doing anything. There are six fields in the line that you can specify: the minute, the hour, the day of the month, the month, the day of the week, and the command to be executed.The instruction to start the launcher using bash is the last entry. The five fields in front of that instruction indicate when the command should be run.
From the Wikipedia entry on cron:
The asterisk * indicates that the job should be run during every time period indicated. So, our launcher will run at 6:59 every day of the month, every month of the year, Monday through Friday.
If you wanted the script to run only once a year, on November 21 at 10am:
00 10 11 21 * /usr/bin/python3 /home/ubuntu/Documents/pythonGmail/wakeup_text.py
To remove a crontab entry from the server:
$ crontab -e