LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-29-2009, 10:02 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Job in /etc/cron.d not working


To be clear, I'm not talking about a user's crontab, I'm talking about the system-wide crontab. These are two different things, tho they operate on similar principles (see man 5 crontab in the "EXAMPLE SYSTEM CRON FILE" section)

Regardless, I've added a file to /etc/cron.d. The file looks like so:

Code:
* * * * * root /root/bin/pwcheck_er
The /root/bin/pwcheck_er script, now at least, looks like this:

Code:
#!/bin/tcsh -f

/bin/date >> /tmp/dater
but /tmp/dater never gets updated.

Any ideas why? I'm not really sure how to even track this down.

Thanks
 
Old 01-29-2009, 10:31 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Try changing:

Code:
* * * * * root /root/bin/pwcheck_er
to:

Code:
* * * * *  /root/bin/pwcheck_er
------------------
Steve Stites
 
Old 01-29-2009, 10:34 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
I've actually never used /etc/cron.d, but according to the cron(8) manpages on my CentOS box:
Quote:
Cron searches /var/spool/cron for crontab files which are named after
accounts in /etc/passwd; crontabs found are loaded into memory. Cron
also searches for /etc/crontab and the files in the /etc/cron.d direc-
tory, which are in a different format (see crontab(5)).
(What distro/version are you asking about, BTW?)

Your crontab entry looks correct -- five date/time items, followed by a user name, followed by a command. Is pwcheck_er executable? Is /bin/tcsh installed on the system? Is the file you added to /etc/cron.d writable only by root? Have you checked root's mail? (stdout and stderr go to the cronjob user's mail by default.) Also, check /var/log/cron (or whatever log crond writes to on your system) for evidence that cronjobs in /etc/cron.d are actually getting run.

Last edited by anomie; 01-29-2009 at 10:35 PM.
 
Old 01-30-2009, 10:50 AM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by jailbait View Post
Try changing:

Code:
* * * * * root /root/bin/pwcheck_er
to:

Code:
* * * * *  /root/bin/pwcheck_er
Actually, I tried that. That said, if you have a look at man 5 cron, you'll see that in system cron jobs, you have to include a user name.

Quote:
Originally Posted by anomie View Post
I've actually never used /etc/cron.d, but according to the cron(8) manpages on my CentOS box:


(What distro/version are you asking about, BTW?)

Your crontab entry looks correct -- five date/time items, followed by a user name, followed by a command. Is pwcheck_er executable? Is /bin/tcsh installed on the system? Is the file you added to /etc/cron.d writable only by root? Have you checked root's mail? (stdout and stderr go to the cronjob user's mail by default.) Also, check /var/log/cron (or whatever log crond writes to on your system) for evidence that cronjobs in /etc/cron.d are actually getting run.
Distro: Debian etch (4.0)

Code:
ash:/etc>ls -l /root/bin/pwcheck_er
-rwxr--r-- 1 root root 921 Jan 29 19:55 /root/bin/pwcheck_er
ash:/etc>ls -l /tmp/dater
-rw-r--r-- 1 root root 29 Jan 29 19:55 /tmp/dater
ash:/etc>ls -l /etc/cron.d/pwcheck_er
-rw-r--r-- 1 root root 36 Jan 29 18:14 /etc/cron.d/pwcheck_er
my crons were not logging in syslog, so I turned them on. hopefully I'll get some useful output in a bit. Have a meeting to go to now. Thanks for the tips. I'll try to post back with results of the syslog. In the mean time, if anyone else has any other ideas, my ears are open.

edit: oh, and yes, root's mail gets forwarded to me.

Last edited by BrianK; 01-30-2009 at 10:52 AM.
 
Old 01-30-2009, 01:23 PM   #5
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
hmm.. so my cron log is empty.

baffled.
 
Old 01-30-2009, 01:47 PM   #6
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Solved. crond had failed somehow. It appeared to be running, but stat'ing it gave garbage. restarted crond & we're happy again. Previously, I'd been "reloading" it rather than restarting it... I never thought that something that appeared to be running might not actually be running.
 
Old 11-03-2011, 09:03 AM   #7
tiekookeit
LQ Newbie
 
Registered: Jan 2009
Location: Brazil
Distribution: debian
Posts: 16

Rep: Reputation: 1
just to say, but sometimes cron.d files fails to load cron jobs on it, just because a empty line at the end of the file is missing, newer versions of cron complains about it
 
  


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
cron job not working bittus Linux - Software 7 04-27-2009 07:39 PM
cron job is not working moagalbm Linux - Newbie 7 02-29-2008 05:16 PM
Cron Job Not Working... ALInux Linux - Software 2 07-24-2007 04:15 AM
Cron job not quite working... simba_cubs Linux - General 10 11-08-2006 06:27 AM
GPG cron job not working michredhat Linux - Software 1 12-07-2004 10:27 PM

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

All times are GMT -5. The time now is 04:49 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