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-10-2015, 06:22 AM   #1
stockton
Member
 
Registered: Jan 2006
Location: Midrand, Gauteng, South Africa
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105

Rep: Reputation: 2
crontab issue


Please tell me what I am doing silly on my Debian Wheezy Raspberry Pi.
I have the following entry in my crontab
*/3 * * * * /home/pi/SocketClient
which, I hope, says that I want to run SocketClient from pi home directory every 3 minutes. It does not ever run.
If I run the bash script /home/pi/SocketClient from the command line it does what is expected and runs the commands it contains.
That script reads as follows
#!/bin/bash
/usr/bin/php /home/pi/SocketClient2.php

and if I run the "/usr/bin/php /home/pi/SocketClient2.php" from the command line it also works.
Both the script SocketClient as well as SocketClient2.php are executable and owned by user pi.
 
Old 01-10-2015, 08:16 AM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by stockton View Post
Please tell me what I am doing silly on my Debian Wheezy Raspberry Pi.
I have the following entry in my crontab
Code:
*/3 * * * * /home/pi/SocketClient
that looks a bit odd, because the 6th column in /etc/crontab should be the user with whose account the command is to be executed (typically root, but can be a regular user as well). Looks like you omitted that entirely.

On my Pi running here, I have just the default crontab with no extra cron jobs added, and it looks like that:

Code:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
Maybe that's the point you're missing.

[X] Doc CPU
 
Old 01-11-2015, 04:24 AM   #3
stockton
Member
 
Registered: Jan 2006
Location: Midrand, Gauteng, South Africa
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105

Original Poster
Rep: Reputation: 2
crontab issue

I tried
Code:
*/3 * * * * root /home/pi/SocketClient
but it still fails. I tried both user pi as well as root.
I am running Raspbmc and I think that that is the issue for it works, as I had it set originally, on Raspbian.
 
Old 01-11-2015, 10:32 AM   #4
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by stockton View Post
I tried
Code:
*/3 * * * * root /home/pi/SocketClient
that looks familiar to me.

Quote:
Originally Posted by stockton View Post
but it still fails. I tried both user pi as well as root.
I am running Raspbmc and I think that that is the issue for it works, as I had it set originally, on Raspbian.
I've never spent much attention to Raspbmc, but is this system using a cron daemon at all?
And I'm amazed that you say your initial sample worked on Raspbian, because I haven't yet seen a system without the user field in /etc/crontab - neither Debian, nor its derivatives Ubuntu and Mint, nor Gentoo, nor Raspbian. How would the cron daemon know which user to assign the cron job to? Would they all run as root?

I'm puzzled even more to find references on the net all showing crontab examples without the user field. Hmm...
By the way, have you tried to enable logging for cron and check the logs for information?

[X] Doc CPU
 
Old 01-11-2015, 11:56 PM   #5
stockton
Member
 
Registered: Jan 2006
Location: Midrand, Gauteng, South Africa
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105

Original Poster
Rep: Reputation: 2
crontab issue

Thank you for your reply.
I have now implemented cron logging and have alter the command in my crontab to
Code:
 */3 * * * * /usr/bin/sudo -H /home/pi/ahbc
The sudo -H is something I found on the web which I am told works.
I don't understand just what the -H is there for.
I have been given to understand that if one does not include the user in a crontab command line that command will run using the user/owner of crontab.
Therefore as my crontab is user pi crontab the contained commands will run for pi.
 
Old 01-12-2015, 05:20 AM   #6
stockton
Member
 
Registered: Jan 2006
Location: Midrand, Gauteng, South Africa
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105

Original Poster
Rep: Reputation: 2
I forgot to say that despite altering the command in crontab it still does not work.

and all I see in /var/log/cron.log is
Jan 12 07:37:13 raspbmc crontab[19356]: (pi) BEGIN EDIT (pi)
Jan 12 07:37:40 raspbmc crontab[19356]: (pi) REPLACE (pi)
Jan 12 07:37:40 raspbmc crontab[19356]: (pi) END EDIT (pi)

which does not help at all. I know that I edited pi's crontab.

---------- Post added 01-12-15 at 01:21 PM ----------

I forgot to say that despite altering the command in crontab it still does not work.

and all I see in /var/log/cron.log is
Jan 12 07:37:13 raspbmc crontab[19356]: (pi) BEGIN EDIT (pi)
Jan 12 07:37:40 raspbmc crontab[19356]: (pi) REPLACE (pi)
Jan 12 07:37:40 raspbmc crontab[19356]: (pi) END EDIT (pi)

which does not help at all. I know that I edited pi's crontab.
 
Old 01-16-2015, 04:14 AM   #7
stockton
Member
 
Registered: Jan 2006
Location: Midrand, Gauteng, South Africa
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105

Original Poster
Rep: Reputation: 2
crontab issue

cron was not running. It is usually the simplest is it not.
 
  


Reply

Tags
crontab



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
Crontab issue preetham.66666 Linux - Server 4 01-11-2015 10:36 PM
crontab issue,need help aditya_moon Linux - Newbie 2 02-07-2011 10:54 PM
crontab issue adnanm Linux - Newbie 1 03-16-2007 02:28 AM
crontab issue houssamfarag Red Hat 2 06-27-2006 11:56 PM
crontab issue lappen Linux - Newbie 6 05-24-2004 05:47 PM

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

All times are GMT -5. The time now is 12:22 PM.

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