LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cronjob did not run (http://www.linuxquestions.org/questions/linux-newbie-8/cronjob-did-not-run-920037/)

casperdaghost 12-22-2011 07:14 AM

cronjob did not run
 
Does anybody see anything wrong with this cronjob
Should I put something in quotes.

I did not run - and I just installed the mail utility (cron seems to send its error messages)

Code:

00 01 * * 1-5 /usr/bin/scp casper@192.168.60.17:/data/binary/filetoTransfer.txt casper@192.168.81.95:/home/casper/
i am careful to put the path to the job in cronjob.
I just want to send something from one remote host to another.

thesnow 12-22-2011 07:34 AM

1. Do you have other jobs in cron that are running OK?

2. What happens when you run this job from the command line?

casperdaghost 12-22-2011 07:36 AM

i actually do not have any other crons running - i will test one

this runs just fine from the command line

Cedrik 12-22-2011 07:43 AM

crontab is running ?
Do you use this crontab as user 'casper'
(do crontab -l when logged as casper to verify)

casperdaghost 12-22-2011 07:46 AM

casper@casperdesktop:~$ ps auxwww | grep cron
root 937 0.0 0.0 2376 856 ? Ss Nov17 0:02 cron
casper 26336 0.0 0.0 3328 912 pts/43 S+ 08:47 0:00 grep --color=auto cron

mmaki 12-22-2011 07:47 AM

Are you using SSH keys to make the connection between hosts or does it prompt you for a password if this is run at the command line? Without SSH keys it will not run from cron.

casperdaghost 12-22-2011 07:48 AM

keys are loaded - i can run the command from the line with out issue

colucix 12-22-2011 08:17 AM

Anything from the cron log, e.g. /var/log/cron or /var/log/message? Did you receive a mail from the cron daemon?

casperdaghost 12-22-2011 08:23 AM

I just installed the mail utility - nothing in either of those error logs

sudo apt-get install mailutils

Cedrik 12-22-2011 08:26 AM

Do you use this crontab as user 'casper' ?
(verify with crontab -l in casper session)

colucix 12-22-2011 08:53 AM

Quote:

Originally Posted by casperdaghost (Post 4556172)
I just installed the mail utility - nothing in either of those error logs

So you need to wait for 1:00 AM to see if something comes out or are you testing the crontab in real time?

Indeed nothing in the logs means that the cron job didn't run at all, as you've anticipated in your first post. Otherwise you should see something like
Code:

Dec 22  1:00:01 localhost CROND[17764]: (casper) CMD (/usr/bin/scp casper@192.168.60.17:/data/binary/filetoTransfer.txt casper@192.168.81.95:/home/casper/)
in /var/log/cron. If this is the case, you have to investigate the proper functioning of the cron daemon. Hence the checklist:

1. Which Linux OS are you running on?
2. Which version of the cron daemon is installed?
3. Is the cron service enabled?
4. Did you successfully run a job in the past, using the casper's crontab?
5. Is the user casper allowed to use crontab (check /etc/cron.allow and /etc/cron.deny)?

casperdaghost 12-22-2011 09:16 AM

it seems that cron is running as root - not casper

casper@casperbox:~$ ps auxwww | grep cron
root 937 0.0 0.0 2376 856 ? Ss Nov17 0:02 cron
casper 26766 0.0 0.0 3328 908 pts/270 S+ 10:15 0:00 grep --color=auto cron
walt@casperbox:~$ sudo service cron restart
[sudo] password for casper:
cron start/running, process 26772
casper@casperbox:~$ ps auxwww | grep cron
root 26772 0.0 0.0 2376 900 ? Ss 10:15 0:00 cron

just tried a test cron and it did not execute
10 13 * * 1-5 /usr/bin/xmessage -file /home/casper/checkCron

casperdaghost 12-22-2011 09:26 AM

Code:

http://unixgeeks.org/security/newbie/unix/cron-1.html

If there is neither a cron.allow nor a cron.deny file, then the use of cron
is unrestricted (i.e. every user can use it).

there is not an allow or deny file in the etc directory

casperdaghost 12-22-2011 09:36 AM

I am running on ubuntu

casper@casperbox:~$ sudo service cron restart
[sudo] password for walt:
Sorry, try again.
[sudo] password for walt:
cron start/running, process 26974
casper@casperbox:~$

thesnow 12-22-2011 10:08 AM

Can you run a cron entry as root (from the root crontab)?

Have you checked this page https://help.ubuntu.com/community/CronHowto? It lists a couple reasons, such as no trailing newline in the crontab file, or a user not in /etc/shadow that could cause the job not to run.


All times are GMT -5. The time now is 04:59 PM.