Adzor Verhaagen
Adzor Verhaagen

Reputation: 55

How to request a job for every first day of the month with GNU date syntax in BASH?

I have a cronjob in a YAML file that currently conducts a check on data from '5 days ago' to 'yesterday'.

I was wondering what could replace the '5 days ago' with something that would always call on the first day the month.

"START=$(date --date=\"5 days ago\" '+%Y%m%d');END=$(date --date=\"yesterday\" '+%Y%m%d')

^^ current format

I've had a look here but there doesn't seem to be an answer unless i've overlooked something.

Any advice welcome

Upvotes: 0

Views: 59

Answers (1)

Piotr Henryk Dabrowski
Piotr Henryk Dabrowski

Reputation: 901

Simply output year and month from the current date, and instead of the current day just print the 1st one:

START=$(date '+%Y%m01')

Upvotes: 4

Related Questions