Trying to set up a cron on azure devops pipeline but I am getting this error message. I looked at the documentation but not sure what is not in line with the doc. Could someone let me know what is wrong with the my cron syntax? Thank you.
Error while validating cron input. Improperly formed cron syntax: '0 21 * * 1-7'.
Here is the entire yml file.
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
schedules:
- cron: "0 21 * * 1-7"
displayName: "pipeline cron test"
branches:
include:
- master
always: true
pool:
vmImage: ubuntu-latest
steps:
- script: echo Hello, world!
displayName: Run a one-line script, changed
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
echo more info
displayName: 'Run a multi-line script'
Here's the relevant part of the doc.
Building Cron Syntax
Each cron syntax consists of 5 values separated by Space character:
1
2
3
4
5
6
mm HH DD MM DW
\ \ \ \ \__ Days of week
\ \ \ \____ Months
\ \ \______ Days
\ \________ Hours
\__________ Minutes
We can use following table to create understand syntax:
Syntax Meaning Accepted Values
mm Minutes 0 to 59
DD Hours 0 to 23
MM Months 1 through 12, full English names, first three letters of English names
DW Days of the Week 0 through 6 (starting with Sunday), full English names, first three letters of English names
Values can be provided in following formats:
Format Example Description
Wildcard * Matches all values for this field
Single value 5 Specifies a single value for this field
Comma delimited 3,5,6 Specifies multiple values for this field. Multiple formats can be combined, like 1,3-6
Ranges 1-3 The inclusive range of values for this field
Intervals */4 or 1-5/2 Intervals to match for this field, such as every 4th value or the range 1-5 with a step interval of 2
You should specify your CRON syntax like the following: "0 21 * * *" or "0 21 * * 0-6", if you want to trigger it for all days of the week.
Days of week: 0 through 6 (starting with Sunday), full English names,
first three letters of English names
Related
I have several pipelines in my project, and I need to schedule them in specific dates.
Is it possible to execute a pipeline every 11th day?
Is it possible to visualize all the pipelines in the project and see the next one to be executed or a table or something with all the pipelines schedules the way I'm working is the "classic view" not YAML.
I am sorry if the doubts seem dumb or something, but I'm searching and I can't find what I am looking for.
Scheduled triggers in YAML cause a pipeline to run on a schedule defined using cron syntax:
mm HH DD MM DW
\ \ \ \ \__ Days of week
\ \ \ \____ Months
\ \ \______ Days
\ \________ Hours
\__________ Minutes
So, if you want it will run every 11th of the month, you can achieve in this syntax:
0 0 11 * *
In your YAML:
schedules:
- cron: "0 0 11 * *" # replace with your schedule
You can use this site to check the syntax.
Regarding your second question, I'm afraid that impossible with YAML pipelines, there is no "table" or something :/
But, it's a good idea, I suggest you create a feature request here.
there is a way to compare between the current time using ansible_date_time
with another date (aws ec2 launch time) So I will be able to know if it happened in the last hour?
I have the following var ec2_launch_time: 2018-01-04T15:57:52+00:00
I know that I can compare days with the following method (from here and here):
"{{ (ansible_date_time.iso8601[:19] | to_datetime('%Y-%m-%dT%H:%M:%S') - ec2_launch_time[:19] | to_datetime('%Y-%m-%dT%H:%M:%S')).days }}"
if I will get 0 I will know that it happened on the same day but I'm looking for a way to get true or false if the difference between the dates are 1 hour (on the same day).
there is a filter for this or elegant way to write this or only using shell (like this)?
By subtracting two dates, you get a timedelta Python object.
You can use total_seconds method to get the exact difference in seconds. Add some basic arithmetic to get the number of full hours:
---
- hosts: localhost
gather_facts: no
connection: local
vars:
date_later: 2018-01-05 08:30:00
date_earlier: 2018-01-05 06:50:00
tasks:
- debug:
msg: "{{ ( (date_later - date_earlier).total_seconds() / 3600 ) | int }}"
returns:
ok: [localhost] => {
"msg": "1"
}
Use the above expression in the condition you want.
I have a cron file that contain this
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
MAILTO="myemail#gmail.com"
* * * * * php /home/forge/biossantibodies/artisan products:exportdiff --env=development
* * * * * php /home/forge/biossantibodies/artisan images:exportdiff --env=development
* * * * * php /home/forge/biossantibodies/artisan publications:exportdiff --env=development
* * * * * mailx -s "CronJob is run successfully" ben#gmail.com
I want it to send email to me after the cron job successfully ran.
I've tried:
MAILTO="myemail#gmail.com"
and:
* * * * * mailx -s "CronJob is run successfully" myemail#gmail.com
And I never received any emails, I looked in the spam folder as well, but I noticed the task between them work.
How would one go about configuring this?
I have run robot suite with 3 tests, 2/3 was passed. After that I run same pybot command with option --rerun first_run_output.xml, 1 test was passed. Next I run rebot -o merged.xml --merge first_run_output.xml rerun_output.xml
In merged.xml the test witch was failed and rerun in merged.xml has starttime="N/A" and endtime="N/A", this value propagate up in xml (parents nodes has also "N/A" value in timestamps)
Reassuming:
- run pybot - A-pass B-pass C-failed -> generate first_run_output.xml
- run pybot --rerun - C-passed -> generate rerun_output.xml
- run rebot -o merged.xml --merge first_run_output.xml rerun_output.xml
- In first_run_output.xml and rerun_output.xml ale starttime and endtime has data value
- In merged.xml in Node <status> for C has starttime="N/A" endtime="N/A" and parents of suite C (thats aggregate A,B,C) also have starttime="N/A" endtime="N/A"
I ask same question on robotframe-user group,
answer is "This is by design"
details: https://groups.google.com/forum/#!topic/robotframework-users/TWvZMtbizrs
I have a console/executable app which I need to configure in autosys which will run every week on Sunday at 12 AM.I have never used autosys. Any help or link will be helpful related with jil command.
insert_job: JOB_NAME job_type: c
box_name: BOX_NAME (if you use one)
machine: servername
owner: account /(which will run the job, must be permissioned on the machine)/
command: whateveryouwanttorun
condition: s(previousjob) /(Means run only if previousjob is in succes state)/
description: "Description Here"
date_conditions: 1 /(1 or y for yes, 0 or n for no)/
starts_time: 00:00 /("00:00" also accepted)/
days_of_week: su
alarm_if_fail: 1 (1 or y for yes, 0 or n for no)
std_out_file: >>path\filename.log
std_err_file: >>path\errorfile.log
There are lots of other options you can invoke like use of a profile or adding variables or dates to log names etc etc. For an explanation of any of these you can ask back here or check google or ca.com for the user guide for the version of AutoSys in use at your place (commonly 11.0 or 11.3.n or possibly 4.5).
Good Luck!