Running a cron job at 11:00 every day? [closed] - cron

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
How do I have to configure a cron job to run every morning at 11:00? I know how to make it run at 11, but not 11:00.
Thanks!

Linux Crontab Format
MIN HOUR DOM MON DOW CMD
0 11 * * * filename
Crontab Fields and Allowed Ranges
MIN Minute field 0 to 59
HOUR Hour field 0 to 23
DOM Day of Month 1-31
MON Month field 1-12
DOW Day Of Week 0-6
CMD Command Any command to be executed
For More info: http://www.thegeekstuff.com/2009/06/15-practical-crontab-examples/

Related

Cron expression not correct for Hangfire Recurring Jobs [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last month.
Improve this question
I have a few jobs configured to be executed on an ASP.NET MVC Site through Hangfire. Hangfire uses a cron expression to trigger said jobs. I thought I had the expression correct, but the triggering is happening too often.
As you can see, the top job just finished executing 6 minutes previously and its next execution is expected to happen in an hour. But the cron expression, as I understand it, says it should only trigger once a day at 2 AM. Even accounting for different time zones, it shouldn't be happening on an hourly basis.
Do I have the cron expression incorrect? I will admit to not being completely knowledgeable about that, though from my reading I thought I had it correct.
Thanks
Old question, but every time I forget this, I end up back here...
Hangfire (at least the version pictured) uses NCrontab (https://github.com/atifaziz/NCrontab) which allows CRON expressions of 5 or 6 parts. If you use 6 parts, the first part is seconds, the second part is minutes. This is why the job in the pictured example was ran at 3:02.
Most answers I have run across seem to only show the 5 part version of CRON expressions.
From the above URL:
* * * * * *
- - - - - -
| | | | | |
| | | | | +--- day of week (0 - 6) (Sunday=0)
| | | | +----- month (1 - 12)
| | | +------- day of month (1 - 31)
| | +--------- hour (0 - 23)
| +----------- min (0 - 59)
+------------- sec (0 - 59)
To trigger once daily at 2am would be 0 0 2 * * ?

Restart the computer when the power on time exceeds 30 minutes [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I was currently controlling this through an uptime.
The computer restarts if uptime is greater than 1h.
But I do not know how to control if the computer is one day on or more, because currently I only control the hours.
Is it possible to control days, hours and minutes with uptime?
I need to restart the computer when the power on time is greater than 1h.
If the time is 1 day and 0 hours gives failure.
Sorry for my explanation, it is a script that does a series of things and alfinal exists this function that is responsible for controlling this parameter.
thanks for reading me
Not sure I quite understand your issue.
If you want your computer to ALWAYS reboot after a specific amount of time, which is very unusual, then use cron. Add this to /etc/crontab (alternatively, if there is a /etc/cron.d directory on your machine, you can also create a file /etc/cron.d/reboot with this content) :
#reboot root sleep 1800; /sbin/reboot
(adapt reboot's path to match your system; 1800 is the number of seconds for 30 minutes, change it to whatever delay you need)
On the other hand, you may be writing a script that will reboot your server, and you may want to keep it from working if it is run before 30 minutes of uptime (which makes more sense).
Then, I understand you have difficulties parsing the result of uptime and you should use /proc/uptime which gives your uptime in seconds:
#!/bin/sh
not_before=1800 # Number of seconds - adapt to your needs
uptime=$(cut -d . -f 1 /proc/uptime)
[ "$uptime" -ge "$not_before" ] && exec reboot
echo "Sorry, only $uptime s of uptime; you must wait $((not_before - uptime)) seconds" >&2
exit 1
If you want to do it in a script, use the result of uptime | grep " day"to determine whether to execute things (in anifcondition), then do anything you want inside theif`.
Make that script executable and put it in crontab to run every 5min or so.
More information on Cron: https://wiki.archlinux.org/index.php/Cron

Cronjob priorities - execution time and exit [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have the following into a crontab and have 7 of these...at range of 15 minutes between one and the other:
50 8 * * * wget -q -O - http://domain.com/path/to/script.php?xxx=3
this script calls mysql, selects every record from a table, does something and updates a certain value...
while usually this script requires about +5minutes to end...and 2 or 3 disappear from running processes...other 3 or 4 do not...it seems they overlap
7020 root 0.0 % wget -q -O - http://domain.com/path/to/script.php?xxx=3
now, can be a priority problem? how to set a priority into crontab (with nice?) ? how priority manages the execution time? with highest priority the process exits before?
if i do mysql > SHOW FULL PROCESSLIST\G
they seem are yet running after 3 hours !
and also...during these sql processes the tables are readable and if not, how to avoid? the pages are served more slowly as usual

In SSHD Configuration what does "MaxStartups 10:30:60" mean? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Problem Is: Some SFTP connections are failing in customer environment
But using sample code if i test with same server no connection is failed.
may be in customer envi many parallel sftp connection started at a time.
I Want to know what is the meaning of MaxStartups 10:30:60
In the above i know only 10 , which means maximum unauthenticated ssh connection allowed.
means at same time 12 sssh connection request comes 2 request fail and 10 success.
What is the mean of 30 and 60 ?
I Want to know what is the meaning of MaxStartups 10:30:60?
10: Number of unauthenticated connections before we start dropping
30: Percentage chance of dropping once we reach 10 (increases linearly for more than 10)
60: Maximum number of connections at which we start dropping everything

Does cron expression in unix/linux allow specifying exact start and end dates

I want to be able to configure something like this.
I want to run job 'X' at 7 AM everyday starting from 29/june/2009 till 30/12/2009. Consider current date as 4/4/2009.
It can be done in a tricky sort of way.
You need three separate cron jobs for that range, all running the same code (X in this case):
one for the 29th and 30th of June ("0 7 29,30 6 * X").
one for every day in the months July through November ("0 7 * 7-11 * X").
one for all but the last day in December ("0 7 1-30 12 * X").
This gives you:
# Min Hr DayOfMonth Month DayOfWeek Command
# --- -- ---------- ----- --------- -------
0 7 29,30 6 * X
0 7 * 7-11 * X
0 7 1-30 12 * X
Then make sure you comment them out before June 29, 2010 comes around. You can add a final cron job on December 31 to email you that it needs to be disabled.
Or you could modify X to exit immediately if the year isn't 2009.
if [[ "$(date +%Y)" != "2009" ]] ; then
exit
fi
Then it won't matter if you forget to disable the jobs.
Yes, mostly. Some cron implementations have support for years, some don't, so we'll assume yours does not. Also, I'm making the assumption that this job is only being run by the cron daemon, so we can use the execute bit to determine whether or not cron should run the job.
Note that you'll need to leave your script as non-executable until such time as you want it to run.
The following cron expressions will do what you want (every day, including weekends). Tweak as you need to:
# Make the job executable on 29 June.
0 6 29 6 * chmod +x /path/to/my/job/script
# Run the job between June and December, only if it's executable.
0 7 * 6-12 * test -x /path/to/my/job/script && /path/to/my/job/script
# Disable execution after 30 December.
0 8 30 12 * chmod -x /path/to/my/job/script
I'm usually a fan of keeping the logic with the program being run. You might think about setting up one cron job that runs the script every day, then have the script decide on its own whether or not it should do anything useful. When the last useful day (Dec 30) has passed, your script could remove itself from the crontab. In the script you can set up the logic with all the comments necessary to describe what you are doing and why.
If your job is a binary program, you might set up a run_script that does this schedule filtering work before calling the program.
You can use this to generate a crontab that runs at specific intervals:
http://www.robertplank.com/cron/
Or this
http://www.webmaster-toolkit.com/cron-generator.shtml
One solution would be to setup 6 crons, 1 for each month, each would run at 7 am every day that month.
It's probably the easiest way, the next one up would be to script it.
No, afaik, you cannot do that.
The cron fields hold the values for minutes, hours, day of month, month and day of week, respectively.
10 5 10 * * means run at 5:10 on every 10th of every month.
10 5 * 12 * means run at 5:10 on every day in december
10 5 * * 1 means run at 5:10 every Monday
You can make it run on a series of specific months, as the crontab format does accept ranges. April through December would be 4-12 in that case for the month field. But that does not take into account your wish for having this limited to 2009.
There is no mechanism to set start and stop dates for cronjob. You can always script this of course. Make a cronjob run every day and check the current date to be before 30/12. If it is 31/12 make it remove itself. Or something more thought through.
A crontab of
0 7 * * 6-12 command_X
would do what you want partially, but it would start at June 1st and run through December 31st. Skipping the first part of June and December 31st would have to be scripted in the X command.

Resources