Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Crontab is not working

Posted on 2006-07-21
9
Medium Priority
?
592 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Accepted Solution

by:
noci earned 600 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 35

Assisted Solution

by:James0628
James0628 earned 400 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 35

Expert Comment

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

 James
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.
Suggested Courses

636 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