Solved

Crontab is not working

Posted on 2006-07-21
9
588 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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 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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

820 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