Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have CRON running every 30 seconds, but that would fall under the crond process correct? Why is sh command sucking up 50% of my CPU when no one is running a Shell Script?

share|improve this question
    
Best of my knowledge, you can't run a cron job at any smaller granularity than 1 minute. Are you doing something special? how many of the cron jobs are running? Maybe it got loose and many are consuming your cpu? (all named similarly so you might not notice only the PID changing) –  lornix Jun 30 '12 at 9:10
add comment

2 Answers

Cron will run the command specified in the command field using sh -c. You can specify another shell by setting SHELL in the crontab file.

EDIT:

Just to clarify, the sh -c command will be ran as a subprocess of cron, which may spawn other subprocesses depending on the command given.

share|improve this answer
add comment

crond runs as root on every system I'm familiar with:

1016 % ps -ef | grep crond 
root       342     1  0 12:37 ?        00:00:00 /usr/sbin/crond

That's on a fairly current Arch installation, but an elderly Slackware says the same thing. If you as some non-root user puts together a crontab file, crond will run the commands as your non-root user ID. The root ownership has been a cause of several major security problems over the years.

As far as using 50% of a CPU, running something heavyweight every 30 seconds could easily consume 50% of a CPU. Lots of "globbing" could do that, I'd think, as could doing a lot of sh-builtin string pattern matching or arithmetic.

share|improve this answer
    
Or it could be consuming 100% of a single core on a dual-core machine... –  killermist Jun 26 '12 at 3:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.