skip to Main Content

Here is my job

45 5 5 2 WED /usr/bin/python3 /home/pi/Saqib/RaspBerryPiAdhan/www/commands/player.py "/static/media/fajr1.mp3" "Office Ustairs speaker" 

Jobs looks fine, as I want it to run only once in a year…however i am using a module called “croniter“…and it seems like it has a bug.

my job is SET to fire only on wed at 5 45, Feb of 5th. however when i use the get_next() method, it returns the next fire date of coming/next wednesday as well.

I need to fire it only ONCE.

my system is Linux Debian kernal.

Anyway around this?

3

Answers


  1. This should do it:

    0 45 5 5 2 ? * /usr/bin/python3 /home/pi/Saqib/RaspBerryPiAdhan/www/commands/player.py "/static/media/fajr1.mp3" "Office Ustairs speaker"
    
    Login or Signup to reply.
  2. If we talk about UNIX/Linux cron record it should be like this:

    45 5 5 2 * /usr/bin/python3 /home/pi/Saqib/RaspBerryPiAdhan/www/commands/player.py "/static/media/fajr1.mp3" "Office Ustairs speaker" 
    

    first you should use number, not name of the day of week. Then in cron relation between minutes, hours, days of month and months is AND. But day of week is in OR relation with days of month. So on your way the script will be executed on the desired date AND every Wednesday

    Login or Signup to reply.
  3. @Romeo Ninov has the right idea!

    Check https://crontab.guru/#45_5_5_2_*

    45 5 5 2 * = β€œAt 05:45 on day-of-month 5 in February.”

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search