Solved

Crontab is not working

Posted on 2006-07-21
9
580 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 39

Expert Comment

by:noci
Comment Utility
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
Comment Utility
I do not have those files. Also, it is not mentioned in my ISP using cron instructions. What else could be wrong?
0
 
LVL 39

Expert Comment

by:noci
Comment Utility
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
 
LVL 39

Accepted Solution

by:
noci earned 150 total points
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:andy7789
Comment Utility
noci, thank you. I will try tomorrow... it is too late here.
0
 
LVL 39

Expert Comment

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

Assisted Solution

by:James0628
James0628 earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Glad you got it working.

 James
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now