LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does the run-parts mean in crontab? (http://www.linuxquestions.org/questions/linux-newbie-8/what-does-the-run-parts-mean-in-crontab-382120/)

mTorbin 11-11-2005 10:34 AM

What does the run-parts mean in crontab?
 
Hey all, in the following line of a crontab file:

01 * * * * root run-parts /etc/cron.hourly

what does the "run-parts" mean?

- MT

acid_kewpie 11-11-2005 10:51 AM

it will run every script in that directory.

mTorbin 11-11-2005 11:06 AM

So... if I were to add THIS to crontab:

* * * * * root run-parts /etc/cron.Intranet

and then in the directory cron.Intranet I were to create a file called IntranetTasks.cron, which inside of IT had :

#!/bin/sh

0 0 1 * * /var/www/cgi-bin/monthlyUpdate.cgi # Runs monthlyUpdate.cgi which creates a new ftpLog file and stores the old one in /var/www/ftpLogs

That would work, right?

- MT

tredegar 11-11-2005 12:41 PM

Quote:

That would work, right?
No. It is simpler than that:

Just put this in your crontab
Code:

# The next line runs monthlyUpdate.cgi which creates a new ftpLog file and stores the old one in /var/www/ftpLogs
0 0 1 * * /var/www/cgi-bin/monthlyUpdate.cgi

If you are putting this into your own crontab, then it might not work as maybe you as a user do not have the permission(s) needed to run that program. If that is the case, put those lines of code into root's crontab:

su - become root
crontab -e edit root's crontab to put in those lines
exit cease being root

acid_kewpie 11-11-2005 01:31 PM

the point of the runparts is to have a really simple place to drop system scripts that will run hourly, daily, weekly etc.. just from the directory they are dropped in. saves you messing with cron if you don't need to.

marciano 11-22-2005 04:11 PM

"Not a directory: /etc/cron.daily" warning
 
I made some changes in crontab and got an error I will describe, so I removed changes but is has not gone. Fedora3

This is the original crontab that worked fine until I added (then removed) some cron tasks.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

I am receiving hourly emails
"Not a directory: /etc/cron.daily"
This dir contains:
inn-cron-rnews
inn-cron-nntpsend

drwxr-xr-x 2 root root 4096 Jul 11 15:38 cron.d
drwxr-xr-x 2 root root 4096 Oct 14 10:29 cron.daily
-rw-r--r-- 1 root root 0 Oct 14 09:49 cron.deny
drwxr-xr-x 2 root root 4096 Oct 14 09:55 cron.hourly
drwxr-xr-x 2 root root 4096 Oct 14 09:48 cron.monthly
-rw-r--r-- 1 root root 265 Nov 23 03:05 crontab
drwxr-xr-x 2 root root 4096 Oct 14 10:29 cron.weekly

I've restarted httpd

What's wrong?
Thanks in advance

tim65 03-06-2008 06:53 PM

Quote:

Originally Posted by marciano (Post 1964263)
I made some changes in crontab and got an error I will describe, so I removed changes but is has not gone. Fedora3

[snip]

I am receiving hourly emails
"Not a directory: /etc/cron.daily"

[snip]


What's wrong?
Thanks in advance


Well, "run-parts" is a shell script, and for every directory it is configured to look at it runs this little test condition (which simply tests that the target is in fact a directory):

Code:

if [ ! -d $1 ]; then

        echo "Not a directory: $1"
        exit 1
fi

For some reason the shell is failing this test even though it is in fact a directory. I have the same problem and have never found any rhyme or reason to it; it happens on some systems, not on others, etc.

You could remove this test altogether from the script, but still ...

acid_kewpie 03-07-2008 04:29 AM

time65, this thread is ancient... why did you reply to it??

Tim_J 11-14-2008 02:10 PM

I know this thread is ancient but I had this problem and all of my net searches keep bringing me here, in the end Redhat support found the solution.
The cause of my "Not a directory" error was a corupt /etc/crontab file. Deleting the crontab file and re-creating it solved the issue.
Appearently, crontab was passing bad info to run-parts.

HowitZer 03-02-2012 12:39 PM

Quote:

Originally Posted by acid_kewpie (Post 3080874)
time65, this thread is ancient... why did you reply to it??

The real question is what is wrong with discussing something at any time? Why does it matter if the thread is years old? Google search will still find the thread even if it's 10 years old.

acid_kewpie 03-02-2012 01:20 PM

Quote:

Originally Posted by HowitZer (Post 4616988)
The real question is what is wrong with discussing something at any time? Why does it matter if the thread is years old? Google search will still find the thread even if it's 10 years old.

Because it's REALLY confusing. People end up wasting a LOT of time by trying to answer questions without realising they were answered YEARS AGO as someone needlessly resurrected a thread. That's why. Also most people literally add NO benefit whatsoever by replying. Like you. This thread was dead for a further 4 years, and you dragged it up for no reason. It's almost as if you did it as a joke, or worse...

HowitZer 03-03-2012 01:41 PM

Quote:

Originally Posted by acid_kewpie (Post 4617009)
Because it's REALLY confusing. People end up wasting a LOT of time by trying to answer questions without realising they were answered YEARS AGO as someone needlessly resurrected a thread. That's why. Also most people literally add NO benefit whatsoever by replying. Like you. This thread was dead for a further 4 years, and you dragged it up for no reason. It's almost as if you did it as a joke, or worse...

Two answers are better than one. It gives the reader increased confirmation they are being steered in the right direction and gives two perspectives.

acid_kewpie 03-03-2012 04:49 PM

Quote:

Originally Posted by HowitZer (Post 4617692)
Two answers are better than one. It gives the reader increased confirmation they are being steered in the right direction and gives two perspectives.

yes, but you gave zero answers. twice.

chrism01 03-04-2012 09:21 PM

Its also the case that system design changes over time, so the answer may not 'work' for the orig qn because the systems are too far apart time-wise.

robinsonaarond 04-27-2012 04:48 PM

System design changes do change over time, but in this case, it hasn't. And thanks to all the recent comments, this showed up as the first search in Google, and gave me exactly what I was looking for; a brief explanation as to crontab's run-parts. The rest was just pure entertainment.

I am a little disappointed in the tone of the comments of acid_kewpie who, as a moderator, I had hoped would show just a bit more restraint. I, for one, agree with HowitZer, and have never seen the point in closing out old threads when they're still useful.


All times are GMT -5. The time now is 08:27 PM.