direct admin, run cron only in week-days - cron

I want to set up cronjob in the Direct Admin panel only while week-days without Sundays and Saturdays. additionally I need run this 3 time a day no certain hours. Can I do that with 1 command?

Sure. To take care of running things only on weekdays, enter a range in the Day of Week field. 0=Sunday, so you want "1-5" in that field. To run a command multiple times, you would use commas to separate the hours you want it to run. For example, to run at 0100, 0900, and 1700, enter "1,9,17" in the Hour field and "0" in the minute field.

Related

cronjob executed on wrong day

I want a script to be executed each first Saturday of a quarter.
Therefore I have set a crontab line up with the following
24 9 1-7 1,4,7,10 6 /absolute/path/to/script
This script was now executed yesterday, at 9:24 (ok),on Saturay (ok), but on October(ok) 16th(NOK).
Any hints what I missed or misunderstood?
Thanks a lot.
The script runs every day the first 7 days and every Saturday of the specified months.
The reason is well explained in this crontab guru page (and crontab(5)'s man page). The relevant piece is:
Note: The day of a command's execution can be specified in the following two fields --- 'day of month', and 'day of week'. If both fields are restricted (i.e., do not contain the "*" character), the command will be run when either field matches the current time. For example,
"30 4 1,15 * 5" would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
You can check that this is indeed what happens by checking the description and when your script will be run next ("next at") here.
The way to achieve what you want, i.e., run the script on the first Saturday, is described in other questions/answers. See, for instance, Run a cron job on the first Monday of every month? or How to schedule to run first Sunday of every month. In short, replace 6 with * and combine your command with a call to date.

How to create cron job to close period each month

I have a project where I have to update a field in my database every 1st day of each month and update it again every 10th after.
This cron allow me to open a session and to close it. I would like to know how can I set up the 10th of the month.
1st day of each month I have : 0 0 1 * *
10th after it : ??
Thanks :)
You can create a Cron expression that passes two dates in the day variable. Something like this would work:
0 0 0 1,10 * ? *
Expression description:
At 00:00:00am, on the 1st and 10th day, every month
You can use the comma in order to pass multiple variables in the day parameter in order to set multiple days to run.
A great resource for playing around with Cron statements is the Cron formatter website, which will let you enter statements, then give you the plain English logic that the statement will follow. It also shows which sections of the statement resolve to minutes, hours, days, ect.. It is really helpful for creating new statements in my opinion.

Is there any way to set year in crontab parameter list?

I want to set a cronjob for a specific date and time.
For example, date time like this 2017 July 12, 12 35.
Is it possible to set Year in the crontab parameter list?
I can set without the year field.
No. Crontab is for events that REPEAT on cycles within the year. It's got no capacity for scheduling events on a particular year, nor even for events that happen in some years and not others. It's just not something the designers of cron needed to do.
There is no parameter to specify the year in crontab.
You can move the year logic to the bash script and add that script to crontab.

CRONTAB changing in script

my task is to make a script which does server snapshots once a day for 7 days, then
once for a week for 3 weeks moving to once for a month for 12 months. And the question is how can I change
frequency of doing snapshots in CRONTAB without changing CRONTAB manually after 7 days then 1 month etc.
I'm afraid that this is three separate entries in the cron table, including start and end time/date. Coding this as a continuing time check from the start date is simply overkill, unless you have some need to restart this sequence every 3-12 months.

cron expression for quartz to start on particular month and repeat every months onwards

I am working on Quartz Scheduler where need to trigger my job on basis of monthly where user can select desired month date from which he want to make it run for every month on that particular date. lets say- I want to schedule quartz job from August 20,2015 which should run every month on 20th, but it should not start by today,must be start on August 20,2015 onward. what would be the cron expression for this?
I have tried a lot to find out the matching thread but did not worked for me.
like if i have to make for every month which start on 20 May 2015 and repeat every 20th date of month the cron expression would be [0 0 12 20 1/1 ? *].for this requirement lot of things available around and works nicely. but how to schedule Quartz which must fire on particular date and repeat onward for every month on that particular date and time?
Please help me out.any link or any guideline would be appreciable.

Resources