0

I have tried by writing the below command in php file and then run that php file from console as well as crontab.The code which i have in php file is like

#!/usr/bin/php -q
<?php
 system ("/usr/local/sbin/googletts-cli.pl -o /var/lib/asterisk/sounds/asdapp/test.wav -s 0.9 -l en -t 'Some text is written here'");
?>

If i run this php file from consol then it is working fine and generate the wav file.But if i put that php file in crontab like

* * * * *  /var/lib/asterisk/agi-bin/asdapp/jagu_test.php

Then it is not generating wav file.

I have also tried the solution which is given in below links:

Why is crontab not executing my PHP script?

PHP script works from command line, not from cron

I have tried with various way for run this php file from crontab but can not get any success.Can anybody know what is the exactly issue or any solution?

Community
  • 1
  • 1
Nency
  • 482
  • 1
  • 8
  • 21
  • try checking your server error log, also try to get email notification of cron tab probably you get some light. – Rikesh Jan 20 '14 at 07:58
  • Thanks Rikesh for your reply.Can you please help me how can i get the email notification and which server log i should check? – Nency Jan 20 '14 at 08:03

1 Answers1

0

Commands executed from crontab and commandline have different environment variables, working path and user (if you don't specify otherwise).

Also, you are invoking PHP interpreter just to invoke a system command. It would be much easier to put this line in the crontab itself:

 * * * * * /usr/local/sbin/googletts-cli.pl -o /var/lib/asterisk/sounds/asdapp/test.wav -s 0.9 -l en -t 'Some text is written here'
opalenzuela
  • 3,139
  • 21
  • 41
  • Actually i am running this command in other php file also which have some other code as well.So can not run this command directly in crontab.But this only command not working in crontab thats why i am trying run as sample php file from crontab. – Nency Jan 20 '14 at 08:01
  • Aha. understood! Well, the first part of my answer (environment variables and path) is still valid. I had several problems related to that as well... – opalenzuela Jan 20 '14 at 08:15
  • I have tried with your answer like directly putting the command in crontab but still same issue there – Nency Jan 20 '14 at 08:27