LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-19-2022, 03:40 AM   #1
Peter_Zorian
LQ Newbie
 
Registered: Jan 2022
Posts: 9

Rep: Reputation: 0
CRONTAB - how to change Times for hourly / daily?


Hi there,

I hope anyone can help here :-)

I'm trying to change the times for the cronjobs daily and hourly...
hourly starts every hour at Minute 01.
And Daily at 03:17 AM.

But my crontab is empty at this time.
And anacron looks this:
###############################################################
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days delay in minutes job-identifier command
1 9 cron.daily nice run-parts /etc/cron.daily
7 55 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly
###############################################################



When I configure a crontab, then the daily and hourly parts are startet twice at the specified time, too...?
Can anyone give me help?

-Zori-
 
Old 01-19-2022, 04:27 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Welcome to LinuxQuestions.

Anacron runs separately from a cronjob and regardless of when the computer is powered on. A daily job can run anytime the computer is on from 0300 - 2200.

Why do you think you need to change times?
 
Old 01-19-2022, 06:14 AM   #3
Peter_Zorian
LQ Newbie
 
Registered: Jan 2022
Posts: 9

Original Poster
Rep: Reputation: 0
Hi,

thanks for answer,

I will change the time because I'm resetting some things, for example the internetconnection.
and I will understand how the crontab works.
I'm sure this had worked. but now the times I configured in the crontab are ignored?

So this is my crontab:
#########################################
*/5 * * * * root run-parts /etc/cron.five-minute
17 * * * * root run-parts /etc/cron.hourly
25 6 * * * root run-parts /etc/cron.daily
47 6 * * 7 root run-parts /etc/cron.weekly
52 6 1 * * root run-parts /etc/cron.monthly
##########################################

and when I configure it, the hourly job stars at minute 01 and minute 17.
I will understand from where the job at minute 01 is comming from?

Last edited by Peter_Zorian; 01-19-2022 at 06:17 AM.
 
Old 01-19-2022, 08:13 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
What linux distribution / version are you running?

cronjobs only run at the specified time. If the computer is off nothing happens.

anacron jobs run regardless. If you turn on the computer at a time different than a cron scheduled time an anacron job will still run.

You have two jobs running, one from anacron and the other from /etc/crontab.
 
Old 01-19-2022, 08:55 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
How are you accessing/editing the crontab?
If with crontab -e , you’re working with the user’s crontab…be that your user or root. I do all my server-side crontab maintenance as root…so su - to root and then crontab -e
There may also be entries in /etc/ crontab and maybe /etc/cron.d/* On my server, rsnapshot updated /etc/crontab

So, crontab for each user, and, maybe, system-wide crontab configs

PS. I also disabled anacron on the server…if it’s not up, I’ve got bigger problems than a missed cron job

Last edited by scasey; 01-19-2022 at 08:58 AM.
 
Old 01-19-2022, 09:18 AM   #6
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,677

Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
What linux distribution / version are you running?
run-parts is Debian-specific, so this must be something Debian-based.

Quote:
Originally Posted by michaelk View Post
You have two jobs running, one from anacron and the other from /etc/crontab.
Well, anacron doesn't run hourly jobs. I think it's rather what scasey says.

Last edited by shruggy; 01-19-2022 at 09:20 AM.
 
Old 01-19-2022, 09:40 AM   #7
Peter_Zorian
LQ Newbie
 
Registered: Jan 2022
Posts: 9

Original Poster
Rep: Reputation: 0
@scasey:

I'm running CENTOS 7.
This is an server, which is runnung 24/7.
So I think anacron isn't necessary or? Because it runs only when the computer starts...


I've only configured the /etc/crontab.
I've checked crontab for every user, inclusive root. nothing in.
And when I put an empty crontab (remove /etc/crontab and "touch /etc/crontab"), then the hourly job runs every "01 Minute" at full hour.
When I configure the /etc/crontab, the hourly jobs are running in addition to the "01 Minute", so here at Minute 17.
I've no idea where the 2nd time is comming...

Like here:
(from the /var/log/cron)
Jan 19 14:01:01 blobbm CROND[3626]: (root) CMD (run-parts /etc/cron.hourly)
Jan 19 14:17:01 blobbm CROND[4166]: (root) CMD ( run-parts /etc/cron.hourly)
 
Old 01-19-2022, 09:57 AM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
I’m guessing the that the second (:01) run is from anacron…had double runs on my CentOS 7 server too.
I shut down (disabled) anacron and that stopped.
I don’t think it only runs at startup/boot, but I’ve not dug into it…as I said, if the server is not running I’ve got way bigger problems than missed cron jobs…
So, I took the quick (lazy) way out and disabled anacron, which made all the duplicate runs go away.

I guess my advice is to grok how anacron works…or not…
 
Old 01-19-2022, 09:57 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
In /etc/ there is
crontab
cron.d
cron.hourly
cron.daily
cron.weekly
cron.monthly
and
anacrontab

cron.d contains 0hourly which runs cron.hourly
01 * * * * root run-parts /etc/cron.hourly

Its cron.hourly that checks to make sure that anacron is running since anacron isn't a service and makes sure the other anacrontab jobs will run.
 
Old 01-20-2022, 03:26 PM   #10
Peter_Zorian
LQ Newbie
 
Registered: Jan 2022
Posts: 9

Original Poster
Rep: Reputation: 0
@michaelk

Thank you, you're the best :-)

I'd never solved this.
This is exactly what I was searching for.
Here is the mysterious check for the RAID too...

Thanks so much...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian daily cron job won't run, but does run in cron.hourly. sandersch Linux - General 7 05-24-2012 01:50 AM
Help understanding rrdtool hourly, daily, weekly, etc bt101 Linux - Software 2 06-29-2011 08:37 PM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
script in cron.hourly not running hourly unholy Linux - Software 2 09-19-2006 08:21 PM
Hourly Crontab Setup gbkyle Linux - Newbie 2 10-06-2004 08:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration