?
Solved

Crontab is not working

Posted on 2006-07-21
9
Medium Priority
?
591 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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