LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-04-2008, 01:15 PM   #1
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Rep: Reputation: 15
PHP script through cron not working fine.


Hello,

I write a PHP script that needs to be run through CRON. I am using Fedora 7 with plesk 8.3.

this script call ffmpeg binary to convert a video file under one of virtual domain hosted on above server, and save the converted file in subfolder subfolder of cron folder.

when I run this php script as same user underwhich I set cron it save the converted file perfectly. however, when I wait for cron to execute. IT does execute the script but doesn't save the converted file. Also it is not sending as message email I put for error tracking.

Can anyone please suggest whats need doing ?
 
Old 09-04-2008, 01:29 PM   #2
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Original Poster
Rep: Reputation: 15
I just try to add the File writting code in my script, and it doesn't do that as well.

However, it does update database.. Can anyone suggest what can do wrong ?
 
Old 09-04-2008, 01:32 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by vikasumit View Post
Hello,

I write a PHP script that needs to be run through CRON. I am using Fedora 7 with plesk 8.3.

this script call ffmpeg binary to convert a video file under one of virtual domain hosted on above server, and save the converted file in subfolder subfolder of cron folder.

when I run this php script as same user underwhich I set cron it save the converted file perfectly. however, when I wait for cron to execute. IT does execute the script but doesn't save the converted file. Also it is not sending as message email I put for error tracking.

Can anyone please suggest whats need doing ?
Have you checked the cron logs to see if you're getting any errors? Also, check the cron job itself...if it's trying to write to a log file (for status messages, etc.), make sure that file and directory exist, otherwise the job will blow off.
 
Old 09-04-2008, 01:43 PM   #4
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by TB0ne View Post
Have you checked the cron logs to see if you're getting any errors? Also, check the cron job itself...if it's trying to write to a log file (for status messages, etc.), make sure that file and directory exist, otherwise the job will blow off.
Hello,

I check the cron log and it shows that cron run on time.. no error reporting.

I run same script through SSH and it execute perfectly, it write log file and save ffmpeg converted video as well. However, when I run it through cron, it won't write log file and doesn't save ffmpeg video as well.

Since it is able to update the Database, I add new table in db for log and run insert query just after my EXEC function for ffmpeg and it does insert in row. but all my tracing data are blank.. except that return value of EXEC php function is 1. (which I suppose is for success ?)
 
Old 09-04-2008, 02:05 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by vikasumit View Post
Hello,

I check the cron log and it shows that cron run on time.. no error reporting.

I run same script through SSH and it execute perfectly, it write log file and save ffmpeg converted video as well. However, when I run it through cron, it won't write log file and doesn't save ffmpeg video as well.

Since it is able to update the Database, I add new table in db for log and run insert query just after my EXEC function for ffmpeg and it does insert in row. but all my tracing data are blank.. except that return value of EXEC php function is 1. (which I suppose is for success ?)

Does the cron job echo data to a log file??? This is what I asked in my first post...if you're putting your info into a log file and you have something like this at the end of the cron job:

/log/job-log-file.txt 2>&1&

you're redirecting stdout and stderr to that file, in that directory. If that directory and log file doesn't exist, your cron job will fail. You can put a ton of commands into your script, and if it's running from the command line, it's working.

Also, you may want to check your path, come to think of it. That user may have php in the path, but since the cron job runs (I assume), as root, php may not be in the path. Try to use an explicit path for the php binary, and see what happens.
 
Old 09-04-2008, 02:22 PM   #6
vikasumit
Member
 
Registered: Apr 2006
Location: Delhi, India
Distribution: Fedore , CentOs, Debian
Posts: 121

Original Poster
Rep: Reputation: 15
I was not logging data in log file as you suggest. I did that nad also I read somewhere that I need absolute path to make it happen, even though my script is doing chdir i still need Complete Abolsute path from / mount point to make it run.

It runs now. Problem is solved .

Summary of POST:

1) Need absolute path
2) Need to log data


Thanks buddy for your help
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
script doesn't run in cron (runs from shell just fine) Timur Sakayev Linux - Software 6 02-26-2007 12:56 PM
php script will not run correctly as cron, fine from cli dtra Linux - Software 2 12-22-2005 07:21 AM
cron issue, php script runs fine in browser and cli dtra Linux - Software 1 07-15-2005 05:45 AM
script runs fine from a command line, but doesn't work from cron? kleptophobiac Linux - Software 5 05-03-2004 04:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration