My level of understanding with Python is extremely limited, so I'm sorry if I don't use the correct terms / ideas here.
I have a Raspberry Pi, and on the crontab, I have a few scripts scheduled to run at certain times each day. These fire every day when I need them to, and it works fine.
There are some days when I need to alter the time some scripts fire, and it's usually in the evening when I need to make an adjustment, changing the time a script runs at night. This change only applies to the day I'm making the change, and the next day, I'd need the scripts to follow their normal schedule. So for instance:
The standard daily script schedule
00 21 * * * python /path/.../script1.py
15 21 * * * python /path/.../script2.py
30 21 * * * python /path/.../script3.py
Some days I need to change this to a slightly changed schedule, like this:
15 21 * * * python /path/.../script1.py
25 21 * * * python /path/.../script2.py
35 21 * * * python /path/.../script3.py
Or like this:
30 20 * * * python /path/.../script1.py
35 20 * * * python /path/.../script2.py
55 20 * * * python /path/.../script3.py
Sometimes the gap between the scripts stays the same, sometimes they don't. Sometimes the scripts will run later in the day, sometimes the scripts will run earlier.
This is just a convenience issue, but sometimes the day after I make this alteration, I forget to go back into the crontab and change the times back to the standard schedule. Most every day needs to be the standard schedule, and these adjustments are essentially one-off changes that happen from time to time.
Is there a way to create a file that has all the standard times listed (a 'master' file of sorts), and schedule it to be installed as the crontab, replacing the crontab that has any changes that may have been made on the crontab the day before? Essentially I want a way to have all the default times for all my scripts (there are many more than 3) revert back after I make any one-off changes. I would likely run that revert process around noon each day.
Thanks in advance for your help!
Related
I am using a product called Mirth to reach out to an SFTP server and download a handful of files on a weekly basis. The product has a cron feature, where it allows you to use a cron expression to do configure this function.
The cron expression I am using:
0 45 13 ? * MON *
NOTE: This is not typical Linux-based cron. It's a cron expression spec used by Java for scheduling things even down to the second (https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm).
Is supposed to reach out at 1:45 PM every Monday and pull down files. But when it reaches out it does so continuously for 20 minutes or so, downloading the same files a few hundred times instead of just once.
Is there vagueness in this expression? It seems like it should only call once. I did just notice that there appears to be a space at the very beginning of the expression, not sure how that would make the thing run for 20 minutes again and again, though.
You could ease your crontab scheduling with crontab generators, like ie. this website:
www.crontab.guru
or
www.crontab-generator.org
(These are first two Google results)
From what you described, it looks like invalid syntax for crontab.
EDITED:
1:45 PM every Monday would be:
45 13 * * 1
I'm struggling with the web based javascript workflow editor in youtrack. what i trying to achieve is to create a summarized list of tasks from current project with the worklog times sums and send that to the project leader.
Unfortunately i cannot achieve that. I'm not very familiar with the syntax and the documentation is pretty weird, maybe somebody of you folks can help me out.
Ok, lets explain what i did:
i created a sheduled workflow and attached to the project
starting coding
now im facing different problems. First i dont even receive a message. Normally the workflow should be fired every minute (for testing) because of the cron:
cron: '* * * * * *',
the next thing is the search rule what i dont really know if its right:
search: 'work time: {This month}',
here i want to get all issues with work time tracked this month
then the next question is how to get access to the tasks, loop thru them and make some operations to summ the worktime.
At least the complete code
What i want to achieve, sending the mail with following content:
JT-42622 with 3,5 hours worktime tracked
JT-XXXXX with 2h
JT-XXXXX with 3h
SUMM: 8,5H worktime out of xxx estimated
In our app, we have an ability to schedule tasks and we converting this functionality to Quartz. One of the problems that I have is scheduling recurring task that should run, for example, every third day.
The cron expression that I had in mind first of all is:
0 37 18 */3 * ? *
But what this will do, is execute that job on 1,4,7, etc... Which is fine, assuming that I want to start from the first day of the month. However, how to deal with this issue if I need to start from 11th?
I could do something like this:
0 37 18 11/3 * ? *
But, in this case, I will always miss all the days before the 11th.
Also, when the time comes for the next month, the expectation that the day of the month will now be different (on one month the job executed on 1st, and on another it could be on 2/3), but based on the cron above it will restart on the same day (e.g. 1st).
I could, of course, count using hours, but then I will have an issue with day light saving?
What is the correct way to organize it? Or am I missing something?
UPDATE
Possible solution is to use simple trigger, as per http://www.quartz-scheduler.org/documentation/quartz-2.1.x/cookbook/BiDailyTrigger.
But in this case, how do I resolve DST problem?
Thanks,
The situation I have is this:
a google form signup where people can sign up for notifications
a series of scripts that I would like to run nightly that looks through the form responses and emails people appropriately, Emailer()
an unsubscribe script that ideally runs frequently (every hour or so would be enough) as well as right before the notifications email is
sent. This looks through the inbox for emails and removes the
appropriate entries from the form responses, Unsubscriber()
I am having trouble coming up with a way to coordinate the way these two scripts will run. What I would like to happen is to have Unsubscriber() run every hour or so throughout the day. At midnight or some late night hour, I would like to run Emailer() once and have the Unsubscriber() function not be running at this time. Once Emailer() completes, I would like the Unsubscriber() function to resume running at its regular interval. I feel like this should be possible using a ClockTrigger, but I can't envision how to make it happen.
I am also wondering, if the Unsubscriber() function is scheduled to run every hour with a ClockTrigger, but takes longer than an hour on a certain instance, will the ClockTrigger start a second instance of the script?
Here is the documentation on how to create manually a time trigger, you can set the function to run every hour.
This trigger could be related to a main function in which you could evaluate the current time, if its in the range of midnight (e.g. 12am < current time > 1am) call the function Emailer(), for every other time of the day call Unsuscriber().
Hope this helps.
I have a task already set up in the Windows Scheduler (on Win Server 2008). It works great but it can put a burden on the system during peak hours (when the box is being used for other things). I currently run the job every 15 minutes. Can Task Sch. be setup to run every 15 minutes but only during a certain window of time. So I could set it up to run every 15 min, but only from 5pm to 5am -- and not run at all from 5am to 5pm?
Set a daily schedule starting at 5pm. In the Advanced dialog, click Repeat task, then specify Every=15 minutes, Until:Time=5am.
Edit: The above instructions are for Windows 2003 Server or XP. If Windows Server 2008 is like Windows 7, then you can do the same thing through the Triggers tab. Set a daily trigger, Start=5pm, Repeat Task Every=15 minutes, For a duration of=12 hours.
You don't need to stick with the pre-defined times - you can type into these fields any value you wish.
For Windows 2008 & above this is what I did:
Create task
Triggers tab
New ...
Use the following settings
In this particular example I want to run the task from 12:06 AM to 23:50 PM.
In "for a duration of" I entered the amount of minutes I want it to run for. Actually you could also enter some thing like 23:50:00 in the "for a duration of" field. It will automatically convert it to minutes after you click OK. That was my experience.
In the triggers tab you can add multiple triggers by using the "New" button. See screenshot below.
You have to set on the the Start field: 5:00:00 AM and on 'for duration of' you have to write '12 hours' or '12:00:00'