Solved

Crontab is not working

Posted on 2006-07-21
9
587 Views
Last Modified: 2010-04-21
Hi X-perts

I am having problems with setting a cron job.

1. I set it as (just to test it every hour)

10 * * * * /usr/local/bin/php /home/.......my path..../test.php

2. I can see this job is in cron (crontab -l is OK)

3. I can run the string "/usr/local/bin .........../test.php" directly from the shell. It is OK also.

the problem is that cron job is not triggered. What could be wrong?

Thanks

-A-
0
Comment
Question by:andy7789
  • 4
  • 3
  • 2
9 Comments
 
LVL 40

Expert Comment

by:noci
ID: 17152726
Do yo have corn.allow or cron.deny files somewhere (/etc , /var/spool/cron and subdirectories?)

if so, add the username to cron.allow or remove the username from cron.deny.

Without these cron won't work for you.
depending on your cron: if there are no files cron.allow or cron.deny files then it might allow all users to use cron.
0
 

Author Comment

by:andy7789
ID: 17152771
I do not have those files. Also, it is not mentioned in my ISP using cron instructions. What else could be wrong?
0
 
LVL 40

Expert Comment

by:noci
ID: 17152961
What is your system and what cron are you using?

(there a quite some variations on unix, also various systems have coices of cron)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 40

Accepted Solution

by:
noci earned 150 total points
ID: 17153078
Does the cronjob expect a certain directory to be run from ?

if please make a wrapper script like:

---8<---
#!/bin/sh        # or whatever you shell ksh/bash is

date >/tmp/last_php_testrun

cd /the/right/directory
/usr/local/bin/php /home/.......my path..../test.php
date >>/tmp/last_php_testrun
---8<---
insert it in a place you like and run this script from cron
don't forget to make the script executable chmod 755 script

The file /tmp/last_php_testrun will show start & stop times of the last run then (to check if your shell script ran)
0
 

Author Comment

by:andy7789
ID: 17153266
noci, thank you. I will try tomorrow... it is too late here.
0
 
LVL 40

Expert Comment

by:noci
ID: 17153291
I'll be on holiday for a few weeks...
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 100 total points
ID: 17159637
How did you set this cron job up?  On at least some versions of Unix, cron only reads the crontab files when cron starts or when the crontab command is used to create/edit a crontab file.  If you edit a crontab file by hand, cron may not see the change until it is restarted, or maybe if the file is then edited using the crontab command.

 If you think that might be the issue, the simplest/surest thing would probably be to shutdown and restart the system and see if the job starts running.  That might be worth a try IAC.

 James
0
 

Author Comment

by:andy7789
ID: 17159813
Thanks everybody. I have fixed it. The problem was that I imported a ready txt file to cron by using crontab command. I do not why, but it did not work, though "crontab - l" showed me a correct job line. I have removed it and created a new job directly via crontab -e.
Thank you again
0
 
LVL 34

Expert Comment

by:James0628
ID: 17159848
Glad you got it working.

 James
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question