bigfry
Posts: 11
Joined: Wed Jun 19, 2013 11:38 pm

crond CPU usage

Wed Jun 19, 2013 11:55 pm

Greetings all.

I happened to notice that crond is maxing out the CPU for about a minute every (other) minute (as reported by top). Is this normal for the Arch distribution on the Pi?

I have not prior to noticing this touched cron. My Pi is currently set up as a pretty stripped down portable PXE server, and I've played around a little bit with python, and installed Samba (but not configured it yet), but other than those - and what was needed for DNSMasque - everything is pretty much stock to the image file that I downloaded last Saturday.

I figured that whatever it's doing would be in the log at /var/log/crond.log, but that is not the case, and I'm not sure where else the usage may be reported at.

Of course, if I stop the cronie service, then it goes away. Honestly, at this point that's not a problem as I don't foresee any need for cron at present, and the box is only on for the few minutes that I'm booting the other computers, but you never know, I may need cron in the future.

Any ideas?

User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: crond CPU usage

Thu Jun 20, 2013 12:12 am

It wakes up every minute to check which cron jobs are due to run. On a machine I have with the same bogomips as a Pi cron has used 14 seconds of CPU in 21 days.

bigfry
Posts: 11
Joined: Wed Jun 19, 2013 11:38 pm

Re: crond CPU usage

Thu Jun 20, 2013 12:24 am

Well on my Pi it's using pretty much 50% (one minute every other minute). When I noticed it, crond was right around 30 minutes of CPU time with my total system uptime being right around an hour.

User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: crond CPU usage

Thu Jun 20, 2013 12:44 am

There is something wrong with your system. Have you added any cron jobs?

bigfry
Posts: 11
Joined: Wed Jun 19, 2013 11:38 pm

Re: crond CPU usage

Thu Jun 20, 2013 4:58 am

That's kind of the direction I was thinking, but this is my first foray into Arch and cronie both, so I'm not 100% sure where all I should be looking for cron tasks.

I have not added any jobs to cron, and according to crontab both root and the user I set up and log in as have no crontab files. If I understand what I've read on cronie I also need to check the cron.* directories under etc, and in those I have:
cron.d/0hourly
cron.daily/logrotate
cron.daily/man-db
cron.daily/shadow
cron.hourly/0anacron
Which to my limited understanding, leaves me with nothing that should be firing every minute.

Now, having said that, on a lark I checked the contents of cron.d/0hourly and it contains

Code: Select all

01 * * * * root run-parts /etc/cron.hourly
, which runs every minute, correct? But surely this can't be the issue can it?

The one other thing that I have thought may have some bearing on it is that the date is reset every time I power it up since it has not internet connection to re-set the date/time. Could cron be having an issue with the date/time being set back to default some of the time, and June 2013 the rare occasions where it does have internet?

User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: crond CPU usage

Thu Jun 20, 2013 10:29 am

I believe cron wakes every minutes to check if any cron jobs need to be run. It should go straight back to sleep if there is nothing to run.

The hourly job you list has 01 * * * * which means run once an hour at one minute past the hour.

You'll need to do something like

ps aux >ps.log

and see which process is using all the time. But, as you say, if it is cron I don't know what to do. Are any logs growing at an alarming rate? On Debian based systems they are in /var/log. Don't know for Arch.

bigfry
Posts: 11
Joined: Wed Jun 19, 2013 11:38 pm

Re: crond CPU usage

Thu Jun 20, 2013 5:02 pm

Well, I have an answer, sort of.

ps was reporting crond as 49% CPU with everything else under 1%. I spent some time just messing around, and checked usage again right at 40 minutes of uptime, and crond at that point had racked up 19:03 CPU time. I hooked up my Pi to the internet and played around a little more, and checked back after 20 minutes, and crond was only up to 19:05. Another 20 minutes later and it had again only racked up a couple more seconds of CPU time.

Not having any other ideas as to what could have fixed it, I left the internet connection, disabled ntpd, and powered off. Brought the Pi back up, and verified the time had reset to December 1969, and watched crond take off. Same as before, crond would take up full CPU usage for one minute every other minute. I left it like that for 40 minutes, then re-enabled ntpd, verified the date/time pulled, and waited another 40 minutes. crond was once again fixed. So I tried again without internet, powered off, let it come up with the reset date/time. Sure enough, crond acted up every other minute. This time I manually set the date to Jan 1, 1999, and have since been running for 15 minutes without any more crond flare ups.

So I'm confident crond is having a problem with the date/time, but it doesn't seem to be because of going back and forth through time, but just that crond doesn't like the Pi's default of Dec1969 maybe. Any ideas on this aspect of it? I wasn't planning on adding the RTC, and most of the time won't be connecting to the internet to auto update the time. Is there a patched or different version of crond that I can drop in? Maybe some fourth or fifth option I'm not seeing?


User avatar
joan
Posts: 13578
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: crond CPU usage

Thu Jun 20, 2013 7:38 pm

I wonder if the problem is related to Dec 1969 being before the epoch? The epoch for *nix systems is the start of the first second in 1970. Time for *nix started then.

sdjf
Posts: 1394
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: crond CPU usage

Fri Jun 21, 2013 2:47 am

I have neither an RTC nor internet connection. I did notice the logs fill up with ntpd early on, so it is disabled on all of my cards, and I watched top for a couple of minutes for cron processes and saw none.

What I think you also ought to run is the following to see if you have any user jobs you are now aware of:

crontab -l

Oh, and joan, yes, our logs are in the same place, /var/log seems to be pretty standard for all Linux.

But one second after boot, the clock gets ticking into and past unix epoch even without setting date/time. If ntpd is disabled, something else is going on, I'd like to see your crontab -l output.

Now, I will confess, I am running a slightly outdated Arch image, so cannot speak for the June images. Maybe I will post back which version of cron I am running on my primary SD card so we can see if our versions are the same.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

bigfry
Posts: 11
Joined: Wed Jun 19, 2013 11:38 pm

Re: crond CPU usage

Fri Jun 21, 2013 3:39 am

Thanks for the code pepedog, your fakeclock does the trick without my having to reinvent to wheel... again. I have now been powered up for 12 minutes, and crond only has 0:00.08 CPU time racked up.

Maybe I have a unique Pi ;) , but when the time is reset it goes to midnight of December 31st 1969 (correction, 16:00 which is UTC-8 - which is my timezone. Now it makes some sense.), and my understanding was also that the epoch is midnight of January 1st 1970 as joan said.

I have done crontab -l sdjf, and it says that there is no crontab for both my user, and root. I'd offer my cron version, but don't know where to find it :oops: I can tell you that crond is 42K, and dated May 21 16:37.

sdjf
Posts: 1394
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: crond CPU usage

Fri Jun 21, 2013 9:36 am

Wow, it looks like cron, crond, crontab do not have the option of asking for the version, just checked man pages, sorry about that. Important feature they forgot to build in! Maybe because cron is standard and does not get changed?

I use something similar to pepedog's fakeclock, and so maybe my Pi might have done what yours does before I started doing that, and I did not notice at that time. I have a number of built in things that check the date/time when I log in as well as once every hour, and the date is "fixed" by them if it is not a current one. So you may not have an odd Pi, it may just be many or most of us have something on board that fixes the date so that we do not notice that behavior of crond.

As long as you found something that works for you, that is all that matters. I had to write my own script for the clock resetting after boot as my pi was crashing almost constantly and needed a different kind of routine as the date that fakeclock was accessing was not helpful under those conditions. Took me two months before my pi got stable as I was setting it up headless with no ability to edit the rootfs from another box.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: crond CPU usage

Fri Jun 21, 2013 11:14 am

Let me tell you a story.
A year ago the fedora remix became available. It was to be the default for the pi.
However being asked to change root password does not go down well with that before-epoch-date

drirr
Posts: 54
Joined: Sun Sep 09, 2012 8:06 am

Re: crond CPU usage

Sat Jun 22, 2013 10:26 am

sdjf wrote:Wow, it looks like cron, crond, crontab do not have the option of asking for the version, just checked man pages, sorry about that. Important feature they forgot to build in! Maybe because cron is standard and does not get changed?
Just use pacman, assuming you're using cronie for handling cron:

Code: Select all

pacman -Q cronie
If not and you don't know which cron-daemon you're using, query your installed packages:

Code: Select all

pacman -Qs cron
But yeah, usually you don't need to query cron about which version you're running. Most, if not all of them work the same so you don't need to do version/implementation specific stuff.
Raspberry Pi (rev 000f, 512MB RAM) with heatsinks and a modmypi case running Arch Linux ARM (armv6h) hooked up to a 750GB 2.5" USB-harddrive

Return to “Arch”