Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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.
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.