I have created a python script which do birthday wish to a person automatically when birthdate is arrive. I added this script on window start up but it run every time when i start my pc and do birthday wish to person also. I want to run that script only once a day. What should i do?
Asked
Active
Viewed 248 times
0
-
Is using an task scheduler an option? – Brenden Price May 26 '20 at 15:44
-
You can do that by creating a service file using `systemctl` utility. – Anwarvic May 26 '20 at 15:44
-
Use your os scheduler to run the script instead. – r.ook May 26 '20 at 15:49
-
After sending the greeting, make a note in a file. Before sending the greeting, check the file to see if you've already sent the greeting. – John Gordon May 26 '20 at 15:49
-
I think task schedular work only on perticular time but i want to make it work like any time when pc start but only once. – Smit Parmar May 26 '20 at 15:53
-
@SmitParmar, I suggest following this tutorial: https://tecadmin.net/setup-autorun-python-script-using-systemd/ – Anwarvic May 26 '20 at 16:09
2 Answers
1
Try this at the start of the file:
import datetime
actualday = datetime.datetime.today().day # get the actual day
actualmonth = datetime.datetime.today().month # get the actual month
bday = 1 # day of birthday
bmonth = 1 # month of birthday
if actualday == bday and actualmonth == bmonth :
# code
it should finish the process if the dates aren't equal

Alessio7
- 26
- 1
0
You can run this program when the system boot How to start a python file while Windows starts?
And after that, you need check the time of when the system started like:
import datetime
dayToday = datetime.datetime.today().day
monthToday = datetime.datetime.today().month
birthdayDay = 1
birthdayMonth = 10
if dayToday == birthdayDay and monthToday == birthdayMonth:
print "HPBD"

AJackTi
- 63
- 2
- 7