Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python Scheduling

# Schedule Library imported
import schedule
import time
  
# Functions setup
def sudo_placement():
    print("Get ready for Sudo Placement at Geeksforgeeks")
  
def good_luck():
    print("Good Luck for Test")
  
def work():
    print("Study and work hard")
  
def bedtime():
    print("It is bed time go rest")
      
def geeks():
    print("Shaurya says Geeksforgeeks")
  
# Task scheduling
# After every 10mins geeks() is called. 
schedule.every(10).minutes.do(geeks)
  
# After every hour geeks() is called.
schedule.every().hour.do(geeks)
  
# Every day at 12am or 00:00 time bedtime() is called.
schedule.every().day.at("00:00").do(bedtime)
  
# After every 5 to 10mins in between run work()
schedule.every(5).to(10).minutes.do(work)
  
# Every monday good_luck() is called
schedule.every().monday.do(good_luck)
  
# Every tuesday at 18:00 sudo_placement() is called
schedule.every().tuesday.at("18:00").do(sudo_placement)
  
# Loop so that the scheduling task
# keeps on running all time.
while True:
  
    # Checks whether a scheduled task 
    # is pending to run or not
    schedule.run_pending()
    time.sleep(1)
Comment

PREVIOUS NEXT
Code Example
Python :: creating a pandas df 
Python :: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel(). y = column_or_1d(y, warn=True) 
Python :: add one day to datetime 
Python :: seaborn correlation heatmap 
Python :: pandas index between time 
Python :: python dictionary rename key 
Python :: replace values in a column by condition python 
Python :: python get file name 
Python :: how to count the occurrence of a word in string python 
Python :: python convert date to timestamp 
Python :: how to plot confusion matrix 
Python :: pyspark dropna in one column 
Python :: hex to rgb python 
Python :: how to detect when a key is pressed in pygame 
Python :: TypeError: expected string or bytes-like object site:stackoverflow.com 
Python :: remove element from list 
Python :: pygame zero how to draw text 
Python :: python slicing nested list 
Python :: root mean square python 
Python :: check remote port is open or not using python 
Python :: pandas sort dataframe by column 
Python :: python challenges 
Python :: delete key value in dictionary python 
Python :: checkbutton tkinter example 
Python :: python cast list to float 
Python :: pyqt disable maximize button 
Python :: how to make a python function 
Python :: how to count number of columns in dataframe python 
Python :: cartesian product pandas 
Python :: list of python keywords 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =