LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
LinkBack Search this Thread
Old 01-18-2010, 07:10 AM   #1
ferventslacker
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Rep: Reputation: 0
Crontab not working for non-root User


Hello, I can't get cron working for a non-root user.

Here's the result of crontab -l for user 'nihi':
Code:
57 12 * * * /bin/date > /home/nihi/logs/testdate
The cron service is running. I have created /etc/cron.allow, which has the contents:
Code:
nihi
root
Additionally, there's no mention of any attempt to run the cron job in /var/log/syslog.

Root's crontab does work. Here's the result of crontab -l for root:
Code:
# m h  dom mon dow   command
30 23 * * * /usr/bin/mpg321 /home/nihi/audio/gwakeup.mp3
00 05 * * * /usr/bin/mpg321 /home/nihi/audio/gwakeup.mp3
which plays that particular mp3 at those particular times as expected.

I'm running Ubuntu 9.10(despite my forum username).

Am I missing something obvious?

Thanks for any help!

Last edited by ferventslacker; 01-18-2010 at 07:43 AM.
 
Old 01-18-2010, 07:14 AM   #2
ferventslacker
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Err... I should add that the crontab for nihi doesn't create a 'testdate' file in /home/nihi/logs/. Which is kind of the crux of the problem, but one I forgot to mention in my post.
 
Old 01-18-2010, 08:45 AM   #3
ferventslacker
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
Well, there seem to be a ton of the 'crontab don't work' type of posts, so I'll give my solution.

I was trying to run offlineimap every five minutes... even if I'd got crontab to work, I'd probably have issues with user environments and so on. What I did instead was write a recursive script using at. The script is /home/nihi/atscripts/recursive-email.sh, and it contains:

Code:
offlineimap
cat /home/nihi/atscripts/recursive-email.sh | at now + 5 minutes
This runs offlineimap every five minutes, and it's kicked off with

Code:
cat /home/nihi/atscripts/recursive-email.sh | at now
Or you could just sh it... you get the idea.
 
Old 01-18-2010, 05:30 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994Reputation: 1994
I don't use Ubuntu, but I'd check other logs eg /var/log/messages. There should be logs of all cron jobs run, regardless of success or failure.
Also, if cron has an issue, it should email the job owner or root.
Try mailx from the cmd line as each user.
 
Old 01-18-2010, 06:19 PM   #5
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 3,975

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
Make sure there is an empty line as last line in your crontab file. Furthermore you should find a message in /var/log/syslog if something goes wrong. The missing empty line in the file will not show up as an error in syslog.

jlinkels
 
Old 01-19-2010, 09:50 AM   #6
ferventslacker
LQ Newbie
 
Registered: Jul 2007
Posts: 8

Original Poster
Rep: Reputation: 0
The lack of an empty line in the crontab file was the problem. It all works now. Thank you very much jlinkels.
 
  


Reply

Tags
crontab


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
crontab for diffrent user than root doesnt work dlugasx Linux - Server 3 07-10-2009 06:38 AM
user crontab and msmtp packages not working together ? frenchn00b Linux - Server 1 04-20-2009 10:10 AM
Crontab not working for user mago Slackware 5 04-03-2006 09:48 PM
GPSD not working from non-root user? Archer36 Slackware 1 03-21-2006 08:54 PM
Crontab "root user" problems... Clubber Lang Linux - General 3 09-30-2004 09:29 AM


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