LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Crontab not working for non-root User (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-not-working-for-non-root-user-782949/)

ferventslacker 01-18-2010 07:10 AM

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!

ferventslacker 01-18-2010 07:14 AM

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.

ferventslacker 01-18-2010 08:45 AM

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.

chrism01 01-18-2010 05:30 PM

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.

jlinkels 01-18-2010 06:19 PM

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

ferventslacker 01-19-2010 09:50 AM

The lack of an empty line in the crontab file was the problem. It all works now. Thank you very much jlinkels.


All times are GMT -5. The time now is 10:08 PM.