My crontab entry is like below:
30 1 9-29 * 1-6 test.sh
I want my cronjob to run at 1:30 AM GMT on dates from 9 to 29 from Monday to Saturday. However, my script (test.sh) is being executed on Sundays also.
I gave the range 1-6 (meaning 1 for Monday and 6 for Saturday).
Can someone tell me where am I wrong or what can be done so that the script does not run on Sundays?
Related
Client give 100 task to employee.
Employee complete 50 task in 1 day
20 task in 2 days
15 task in 3 days
4 task in 4 days
5 taak in 6 days
6 task in 10 days.
Now I want to know on a average how many days employee will take to complete for 1 task
Need formula for this query..
Assuming tasks are not completed in parallel (i.e. days are mutually exclusive with respect to completing/working on tasks), average days per task = 0.26:
=SUM(B2:B7)/SUM(A2:A7)
This is where the solution should terminate - however, I provide a number of checks/alternative approaches which serve to demonstrate (unequivocally) the veracity of the above function...
checks
check 1
The same can be derived using the 'weighted average calculation:
=SUM((B2:B7/A2:A7)*A2:A7)/SUM(A2:A7)
check 2
Intuitively, if each task takes ~0.26 days to complete, and there are 100 tasks, then the total duration (days) ~= 26: summing column B gives just that:
check 3
If still unconvinced, you can calculate the average days per task for each category/type (i.e. for those that take 1,2,3,.., 10 days to complete):
=B2:B7/A2:A7
Then expand these out using sequence / other method:
=SEQUENCE(1,A2,G2,0)
Again, this yields 0.26 and which should confirm (unequivocally) the veracity of the simple/direct ratio...
Ta
I saw 2 discussions on bi-weekly job. However, both don't have a precise solution to this technical requirement. That's why, I am starting this thread.
I have a requirement to run a DAG every alternate Friday at 5 PM. So, if I start my DAG on 19 Mar, 2021, then it should run on the 19th of Mar, 2021 and the subsequent runs should happen on alternate Fridays. This would mean that after 19th Mar, 2021 the next run should happen on 02 Apr, 2021. How can I achieve it?
Thanks in advance!
After lot of deliberations and help from many in the community, I got the answer from AirFlow slack community.
def _skipcondition(execution_date, **_):
first_valid_friday = datetime(2021, 4, 9)
return (execution_date - first_valid_friday).days % 14 == 0
with DAG(dag_id='fortnightSchedule',default_args = default_args, schedule_interval = "0 17 * * 5", catchup=False) as dag:
check_valid_friday = ShortCircuitOperator(
task_id="check_if_correct_friday",
python_callable=_skipcondition,
provide_context=True,
)
rest_of_tasks = DummyOperator(
task_id="dependent_dummy",
)
check_valid_friday >> rest_of_tasks
Its a simple function that returns True when the number of days between execution date and first execution date is divisible by 14.
Thanks for your help.
I do not think there is any straightforward way to do this, but I can provide some valid approaches by which you can do it.
Option 1
Set the schedule to 0 17 * * 5 - which translates to At 17:00 on Friday.
Use a BranchPythonOperator to get the last dag successful branch run date from airflow variables and check if it is 14 days from the current run date.
The date will be stored as an airflow variable and updated only when the true branch (alternate Friday runs) succeed.
If yes, continue the rest of the DAG, else, skip the rest of the tasks. An example of how to implement this is given in the above-mentioned link.
Option 2
Set the schedule to something like 0 17 1,14 * 5 - which translates to At 17:00 on day-of-month 1 and 14 and on Friday. This will run twice a month.
Note: Option 1 is preferred over Option 2 as it will help tackle the requirement as expected.
Hope these help!
I think you can use datetime.timedelta function.
you can execute DAG after 14days based on start_date.
using this you can execute DAG below day.
2021-03-19
2021-04-02
2021-04-16
2021-04-16
....
this can be the example.
import datetime
dag = Dag(
dag_id="bi_weekly_dag",
schedule_interval=datetime.timedelta(days=14)
start_date=datetime.datetime(year=2021, month=4, day=19)
)
I already achieved to get calendar days:
*** Test Cases ***
Get Date & Time on Banner
${date_var} get text ${LOCATOR}
log ${date_var} console=yes
${time} Get Time NOW
${plus} Add Time To Date ${time} 14 days
${convert} Convert Date ${plus} result_format=%Y-%m-%d %H:%M
log ${convert} console=yes
Should Be Equal ${date_var} ${convert} ELSE Log console=yes
Output is Pass:
2020-07-10 10:24
2020-09-16 16:30
Could someone help how to achieve calc against system date for business days (excluding weekdays/holidays)?
Qt 5.5 QDateTime::addSec function has returned a wrong value in a last day of a month if add 12 hours (43200 secs).
I's got the following result today 30 november 2015:
1.
QDateTime::currentDateTimeUtc().addSecs(43200);
output (run time - 2015-11-30T10:05:50):
date - Mon Nov 30 10:05:50 2015 GMT
2.
QDateTime::currentDateTimeUtc().addSecs(21600);
output (run time - 2015-11-30T10:08:12):
date - Mon Nov 30 16:08:12 2015 GMT
3.
QDateTime::currentDateTimeUtc().addDays(1).addSecs(-43200);
output (run time - 2015-11-30T10:11:08):
date - Tue Dec 1 10:11:08 2015 GMT
I want to add 12 hours and get 2015-11-30T22:11:08
How to avoid this situation? Is it a bug in Qt or I do something wrong?
Note that QDateTime QDateTime::addSecs(int s) const is a const function, that means, it does not change this object. You need to evaluate the returned object:
QDateTime dt = QDateTime::currentDateTimeUtc().addSecs(43200);
... output dt ...
Also from the latest documentation (Qt Documentation for version 4.8 did not have this):
Note that the time will wrap if it passes midnight.
Whatever this means...
I wrote a small example. And everything works as expected. I think It's environment issue. Thank you everyone!
Is it possible to save the whole sequence of commands from a specific day, from RStudio, into a file? If yes, how?
RStudio saves the history in ~/.rstudio-desktop/history_database (*NIX).
It saves the line of code and a running id which is seconds/1000 till epoch.
cmp as.numeric(Sys.time()).
So, as.numeric(Sys.time()-60*60*24)*1000 is the about the time index 24h back in time.
However, the location of the history_database file may be platform dependent.
To me the following worked:
# get the file to table
h<-read.table("~/.rstudio-desktop/history_database",sep=":",fill=T,stringsAsFactors=F)
# convert timestamps to numeric, note that some are converted to NA
h$V1<-as.numeric(h$V1)
# enter time from when on you want to have your history
from<-as.numeric(as.POSIXct("2014-03-27 10:00:00 CET"))*1000
# accordingly
to<-as.numeric(as.POSIXct("2014-03-27 13:00:00 CET"))*1000
# I also want the lines with NA timestamps within my time window
min<-min(which(h$V1>from & h$V1<to))
max<-max(which(h$V1>from & h$V1<to))
# this are lines you typed between 10:00 and 13:00 on 27th of march 2014
h$V2[min:max]
# save to file
f<-file("history.txt")
writeLines(h$V2[min:max], f)
close(f)