duanbai1974 2014-05-04 13:48
浏览 85

perl脚本没有通过cron运行

I need your help here. I wrote one PERL script for PHP application which needs to be run for every 5 mins. This script will call PHP program, which will fetch data from MySQL DB and will generate a excel report and will mail those reports to specific users. Every thing seems to be fine when I ran this script manually with the command (perl reports.pl). But when I set this Perl in a cron tab, nothing works and reports are not getting generated.

Details: perl script path /opt/app/deweb/web/EDI/Microsoft/reports.pl

this script will call PHP program (/opt/app/deweb/web/EDI/Microsoft/reports.php)

content of script
#!/usr/local/bin/perl
use Net::FTP;
use File::Copy;
use POSIX;
@errorreport = `php /opt/app/deweb/web/EDI/Microsoft/reports.php`;
print "@errorreport
";
exit;

It is working perfectly when running Manually using command - perl reports.pl

No results, when set in CRON:

*/5 7-19 * * * /usr/local/bin/perl /opt/app/deweb/web/EDI/Microsoft/reports.pl

Please note that this crontab is under super user account named webserv and my login is having access to edit under this super user account. I'm editing this cron tab using command :: sudo -u webserv crontab -e

  • 写回答

2条回答 默认 最新

  • duanliang1019 2014-05-04 15:56
    关注

    I would check the following:

    1. Does it run using sudo -u webserv perl reports.pl? If not, fix the problem for the webserv user (permissions or whatever) and it should work via cron too.
    2. Does which perl using your login give you /usr/local/bin/perl? If not, change the path to Perl in crontab to what you got in which perl to fix the problem.
    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发