Perl can't find module when run from cron.daily

前端 未结 2 1176
梦毁少年i
梦毁少年i 2021-01-05 12:49

I have perl programs that use Net::Finger and have run successfully from cron.daily in Fedora 11.
I just upgraded a server to Fedora 18 and the

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 13:10

    What happens if you add this to the top of the script?

    #!/usr/bin/perl
    use lib "/root/perl5/lib/perl5/Net";
    

    Was this previously set in the .profile?

    This is from a ubuntu thread, but may be related: https://askubuntu.com/questions/23009/reasons-why-crontab-does-not-work *Cron passes a minimal set of environment variables to your jobs. To see the difference, add a dummy job like this:

    * * * * * env > /tmp/env.output*
    

    I don't have a linux box handy at the moment, but I would try to see what's different in the @INC by running the following logged in as root and trying to set up a job to see what the crontab has. The env output above may indicate a different shell is being used by crontab, than what you may have set when logging in as root.

    log in as root and run:

    perl -le 'print for @INC'
    

    set up a cron job to see the differences. I'm not sure if this syntax will work, but you could put the command in a simple pl script.

    * * * * * perl -le 'print for @INC' > /tmp/inc.output
    

    do the same for env

提交回复
热议问题