LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-11-2005, 10:34 AM   #1
mTorbin
LQ Newbie
 
Registered: Nov 2005
Location: Philadelphia, Pa
Posts: 7

Rep: Reputation: 0
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
 
Old 11-11-2005, 10:51 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
it will run every script in that directory.
 
Old 11-11-2005, 11:06 AM   #3
mTorbin
LQ Newbie
 
Registered: Nov 2005
Location: Philadelphia, Pa
Posts: 7

Original Poster
Rep: Reputation: 0
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
 
Old 11-11-2005, 12:41 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,034

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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
 
Old 11-11-2005, 01:31 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
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.
 
Old 11-22-2005, 04:11 PM   #6
marciano
Member
 
Registered: Oct 2005
Location: Uruguay
Distribution: CentOS 5.10 Ubuntu 12.4 MacOS 10.9
Posts: 113

Rep: Reputation: 17
"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

Last edited by marciano; 11-22-2005 at 04:13 PM.
 
Old 03-06-2008, 06:53 PM   #7
tim65
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by marciano View Post
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 ...
 
Old 03-07-2008, 04:29 AM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
time65, this thread is ancient... why did you reply to it??
 
Old 11-14-2008, 02:10 PM   #9
Tim_J
LQ Newbie
 
Registered: Nov 2008
Location: Southern Maine
Distribution: RHEL 5
Posts: 1

Rep: Reputation: 0
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.
 
Old 03-02-2012, 12:39 PM   #10
HowitZer
LQ Newbie
 
Registered: Mar 2007
Distribution: Fedora Core 6, Fedora Core 4
Posts: 22

Rep: Reputation: 0
Quote:
Originally Posted by acid_kewpie View Post
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.
 
Old 03-02-2012, 01:20 PM   #11
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
Quote:
Originally Posted by HowitZer View Post
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...

Last edited by acid_kewpie; 03-02-2012 at 01:23 PM.
 
Old 03-03-2012, 01:41 PM   #12
HowitZer
LQ Newbie
 
Registered: Mar 2007
Distribution: Fedora Core 6, Fedora Core 4
Posts: 22

Rep: Reputation: 0
Quote:
Originally Posted by acid_kewpie View Post
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.
 
Old 03-03-2012, 04:49 PM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
Quote:
Originally Posted by HowitZer View Post
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.
 
1 members found this post helpful.
Old 03-04-2012, 09:21 PM   #14
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
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.
 
Old 04-27-2012, 04:48 PM   #15
robinsonaarond
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
run-parts gives error on bash script ChoKamir Programming 7 08-18-2014 07:31 AM
crontab and run-parts gavinbeatty Slackware 4 09-13-2005 07:56 PM
Script doesn't run in crontab dani81 Linux - General 1 11-16-2004 04:42 AM
How to run useradd from crontab? adrianphicks Linux - Enterprise 3 08-03-2004 01:00 AM
Can't run F-Prot with Crontab maxflex Slackware 7 07-31-2004 11:11 AM


All times are GMT -5. The time now is 06:40 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration