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.
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105
Rep:
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.
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 )
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105
Original Poster
Rep:
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.
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?
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105
Original Poster
Rep:
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.
Distribution: Raspbian, Mint 13, Slackware 14, Debian & Ubuntu
Posts: 105
Original Poster
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.