LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-23-2009, 05:07 PM   #1
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Rep: Reputation: 1
Admin Cron Job Not Running


I found a number of threads such as this, but the scenarios are all a little different so I'm starting my own. I'm wondering if this is a permissions thing...Here is the scenario (forgive me if my terminology is off):

Under /var/spool/cron there is an admin crontab with a script that is set to run at 4am every day. The script itself and the content aren't important I don't think because the job itself never runs, but here it is in case it helps:

Quote:
0 4 * * * /mydirectory/apps/amalgamaton/bin/amalgamaton.sh -u 2>&1 | mail -s "amalgamation update" me@myemail.com
* * * * * /bin/echo "foobar" >> /home/admin/cron.test
.

I followed the troubleshooting tips at http://aplawrence.com/Unixart/crontab_not_running.html: I verified mail can be sent, I checked the logs, made sure crond was running, I added a test script to the admin and root crontabs to write "foobar" to the cron.test document (the second line in the above crontab). The root crontab worked as expected (same script, different directory), and the results of /var/log/cron shows the command running every minute as it should. There is no such result for the same thing for the admin crontab. It shows crontab being reloaded after I make the changes to the file, but that's it. It never appears to run. The article I referenced above mentions something about permissions on the crontab.

Quote:
In this version of cron, /etc/crontab must not be writable by any user
other than root. No crontab files may be links, or linked to by any
other file. No crontab files may be executable, or be writable by any
user other than their owner.
Could this be my problem? Here are the permissions for the admin crontab:

Quote:
[root@server ~]# ls -ll /var/spool/cron/admin
-rw------- 1 root root 184 Nov 23 16:36 /var/spool/cron/admin
Do I need to chown and chgrp to admin for this to run?

Thanks in advance for your assistance.
 
Old 11-23-2009, 05:15 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Maybe just two silly questions but... here we go:
1) Is "admin" an actual user of your system (is it listed in /etc/passwd)?
2) Have you checked the content of /etc/cron.deny?
 
Old 11-23-2009, 05:19 PM   #3
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
Not silly at all. Yes, admin is a user on the system (checked /etc/passwd), and there's no content in /etc/cron.deny.
 
Old 11-23-2009, 05:19 PM   #4
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,027
Blog Entries: 5

Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
/var/spool/cron/crontab/<user> should be owned by the user it runs as.

Therefore you need to make /var/spool/cron/crontab/admin owned by user "admin" not user "root".

The admonition about /etc/crontab was not meant to cover all of /var/spool/cron/crontab files. If you had a root file in /var/spool/cron/crontab it should be owned by root but only because root is the user for that file.

No user other than the owner should be able to write to any of the /var/spool/cron/crontab files. Anyone that could write to them could make jobs run as that user.
 
Old 11-23-2009, 06:50 PM   #5
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
If the first job fails to run due to a cron issue, root or the job owner should get an email as to why.
Try mailx from the cmd line as both users.
Incidentally, is amalgamaton.sh really spelt like that and not amalgamation.sh ?
 
Old 12-03-2009, 05:28 PM   #6
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
Sorry for the radio silence. Unfortunately, this is a client that I only see about once a week so I haven't been back until today.

Yes, amalgamaton.sh is the correct spelling. I checked and made sure that the path indicated in the script is correct as well. I also get no mail for the root user pertaining to this job, nor does the Admin user whose script it is receive any email that the job has failed.

I thought I had changed the ownership after jlightner's post, but after checking permissions again it still shows as owned by user root. I have changed it to admin (again) and will see how that pans out.

Thanks for the advice!
 
Old 12-07-2009, 09:50 AM   #7
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
Well, I changed the permissions and they stuck and the job is still not running, at all. It's as if crond doesn't even see it. I'm out of ideas other than adding this script to cron.daily and letting it run from there.
 
Old 12-07-2009, 10:44 AM   #8
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,027
Blog Entries: 5

Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
Did you restart cron after changing the permissions?
 
Old 12-07-2009, 12:59 PM   #9
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
Can I add one more thing to this that maybe someone can confirm may or may not be related?

The environment uses Likewise/Samba for authentication. There is a Windows group defined in ADUC, Linux Admins. There is a line in the Likewise config file saying that a user must be a member of this group to log in to the system. The admin account is not a member and therefore cannot directly ssh into the system (this is on purpose). Users can sudo to admin once logged in and run commands however. I also notice that around 4am every day (the same time the cronjob should run for the user admin) /var/log/messages has this entry:

Quote:
Dec 7 04:00:01 server lsassd[26384]: 0xb5552b90:Error: User [admin] not in restricted login list
I'm grabbing at straws and trying to make a connection. I don't see how denying an account the ability to ssh would affect its ability to run a cronjob, especially since users are able to kick off the desired script manually once sudoed to the admin account, but the fact that the error is logged around the same time as the job is supposed to run makes me wonder...
 
Old 12-07-2009, 01:00 PM   #10
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
@jlightner: nope, sure didn't! Will do now.
 
Old 12-07-2009, 01:11 PM   #11
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,027
Blog Entries: 5

Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
Quote:
Dec 7 04:00:01 server lsassd[26384]: 0xb5552b90:Error: User [admin] not in restricted login list
Since it is an "Error" and occurs at the time the cron job runs it seems extremely likely this is your issue. The good news is that it tends to confirm your cron is trying to run.

You might want to set a different time (e.g. 5 minutes from now) on your foobar test line in admin's cron and see if gives the error when that tries to run. If so it confirms it is the issue.

The error suggests the fix is to add admin to the restricted login list.
 
Old 12-07-2009, 02:40 PM   #12
Subject16
Member
 
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
Well, that is indeed the problem! I checked that log and the same message is being reported every minute, right along schedule with the cron job that is trying to run. I have the problem, now I will work on the solution (starting with figuring out what this restricted login list is). Thanks so much for your help!
 
  


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
Cron Job is not running akshathajagadish Linux - Newbie 2 10-15-2009 08:21 PM
Running a Cron Job landysaccount Linux - Newbie 6 02-04-2009 06:29 PM
cron job not running vincebs Linux - Software 34 10-30-2004 02:27 PM
Cron job not running? james_cwy Linux - Newbie 6 12-14-2003 09:24 PM
Cron Job Not Running pzorn Linux - General 4 10-02-2003 02:38 PM


All times are GMT -5. The time now is 02:59 AM.

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