in reply to Crontab "Can't open perl script", " No such file or directory"

Hi,

as cron is throwing away most environment variables I do want to have a script run exactly like I would do it on the console. I use two ways:

You want to collect all cron jobs in one crontab of root but want to run them with a certain uid:

* * * * * su - user -c '/usr/bin/perl /home/myuser/scripts/perl/flash. +pl'

or you run it in the crontab of the user and force an environment as if you have logged in:

* * * * * bash -l -c 'usr/bin/perl /home/myuser/scripts/perl/flash.pl'

Probably this would also trigger the mounting of your home directory if this is the reason for your problem.

Regards
McA

Replies are listed 'Best First'.
Re^2: Crontab "Can't open perl script", " No such file or directory"
by Anonymous Monk on Oct 09, 2014 at 16:47 UTC

    Given the reply earlier about single hard drive on laptop, I would think that the directory (or, parent) would be already mounted and thus removes automount or similar. (The explicit question was still not answered.)

    Could it be possible that that a bad "shebang" line (not shown), if present, would be causing the problem even though the program is started explicitly via /usr/bin/perl per OP?

      That would be a very odd situation indeed considering he said it does run sometimes. If there was an issue determining what binary would interpret the file, it shouldn't ever run.

        successful execution manually:
        :~$ bash -l -c '/usr/bin/perl /home/myuser/scripts/perl/flash.pl' running for: 2014-10-08 get, success 148847 bytes of data. Number of rows affected: 0 :~$ /usr/bin/perl /home/myuser/scripts/perl/flash.pl running for: 2014-10-08 get, success 148847 bytes of data. Number of rows affected: 0 :~/scripts/perl$ ./flash.pl running for: 2014-10-08 get, success 148847 bytes of data. Number of rows affected: 0
        :~$ bash -l -c '/usr/bin/perl /home/myuser/scripts/perl/flash.pl' running for: 2014-10-08 get, success 148847 bytes of data. Number of rows affected: 0 :~$ /usr/bin/perl /home/myuser/scripts/perl/flash.pl running for: 2014-10-08 get, success 148847 bytes of data. Number of rows affected: 0 :~/scripts/perl$ ./flash.pl running for: 2014-10-08 get, success 148847 bytes of data. Number of rows affected: 0
Re^2: Crontab "Can't open perl script", " No such file or directory"
by Anonymous Monk on Oct 09, 2014 at 15:07 UTC
    I just put in, bash -l -c, and will take a look tomorrow.