1. KrisScott

    KrisScott New Member

    Messages:
    33
    Version Parallels Plesk Panel v10.4.4_build1013111102.18 os_CentOS 6
    OS Linux 2.6.32-220.4.2.el6.x86_64


    I have a perl script.
    It works through cgi-bin of the domain, e.g. mydomain.com/cgi-bin/script.pl
    It works through command line via ssh /usr/bin/perl /var/www/vhosts/mydomain.com/cgi-bin/script.pl

    It fails when set as a scheduled task from plesk panel using path /usr/bin/perl /var/www/vhosts/mydomain.com/cgi-bin/script.pl

    I get this error in my email:
    Any suggestions/help is very much appreciated.

    Thanks,
    Kris
  2. burnleyvic

    burnleyvic Kilo Poster

    Messages:
    168
  3. KrisScott

    KrisScott New Member

    Messages:
    33
    Thanks burnleyvic

    I had found that article a couple hours back.
    Unfortunately i don't think it is to do with ascii characters lf/cr.
    The script was downloaded from my other server that is running the exact same plesk and centos versions. It works there from cron. Uploaded in binary to new server and it works except when executed by cron.

    To test this further I wrote a simple script to just print "this is a test" and set that as a cron also. It failed with the same error message but executes fine from cgi.

    The only difference is that one server is an AMD opteron and the other is a XEON. Everything else is the same.

    I'll give this another hour of my time and if it isn't resolved I think its best to reinstall from a different mirror choosing something other than Plesk. I'm a bit fedup with Plesk since version 10 arrived. Nothing but problems.
  4. burnleyvic

    burnleyvic Kilo Poster

    Messages:
    168
    Kris, is PATH correctly set by cron? Try to run a bash script instead of the perl one, perhaps displaying the output of 'stat /usr/bin/perl' shell command.
    You may also want to check if Plesk has configured the chroot environment correctly for that account. Is /usr/bin/perl available in the chroot?
  5. KrisScott

    KrisScott New Member

    Messages:
    33
    Never done anything with bash so have no idea what you are asking. But thanks for your help. I'll have to learn a bit before I can try what you say. Just wish Plesk worked 'out of the box' instead of having to muck around with it to get it going.

    Is there a log file somewhere that I can view cron errors?
    Last edited: Feb 26, 2012
  6. KrisScott

    KrisScott New Member

    Messages:
    33
    My workaround - leave crons not working on this server and trigger the scripts from the cron on a working server using LWP.

    Not the best solution by far.
  7. burnleyvic

    burnleyvic Kilo Poster

    Messages:
    168
    Kris, create a file called test.sh with the following content and make it executable:

    #!/bin/bash

    echo $PATH >> /tmp/test.out
    stat /usr/bin/perl >> /tmp/test.out

    Then configure a cron job to run it the same way you'd do for the Perl script.
    Cron errors are usually emailed to root. If you've set up an alias to collect the email to root you should see emails generated by the failed cron jobs.
  8. KrisScott

    KrisScott New Member

    Messages:
    33
    Thanks again burnleyvic.

    I did what you suggested. The email response is the same.

  9. burnleyvic

    burnleyvic Kilo Poster

    Messages:
    168
    I don't understand what you did. Did you use the shell script instead of the perl one? If you remove any existing /tmp/test.out and run the shell script from cron, what's in that /tmp/test.out file?
  10. KrisScott

    KrisScott New Member

    Messages:
    33
    I put the script in two different folders.

    First folder is /usr/local/bin which is in $PATH
    A cron with path /usr/local/bin/test.sh didn't create an outfile but sent me the email message that the directory/file wasn't found.
    If I open a terminal, and then bash /usr/local/bin/test.sh I get an out file with content....
    Second folder that I place test.sh is the cgi-bin folder where the scripts are that I was trying to cron.
    A cron for /var/www/vhosts/mydomain.com/cgi-bin/test.sh didn't produce an outfile but sent an error email.
    Again, if I open a terminal and use bash /path to test.sh, it then produces the test.out file with content...
  11. burnleyvic

    burnleyvic Kilo Poster

    Messages:
    168
    I'd suspect there's a problem with your chroot environment. What's the complete error message in that email?
  12. KrisScott

    KrisScott New Member

    Messages:
    33
    The email just contained this

    -: /var/www/vhosts/mydomain.com/cgi-bin/test.sh: No such file or directory

    Thanks very much for your continued help on this.
  13. burnleyvic

    burnleyvic Kilo Poster

    Messages:
    168
    Heh, I've reproduced yur problem. Looking in /var/spool/cron/mytestuser I could see that the cron is configured to run under a restricted shell, I have "SHELL=/usr/local/psa/bin/chrootsh" in that file. As soon as I commented this entry out the path to the executable file was found. Then I found this page:
    http://download1.parallels.com/Ples...inistrator-guide/index.htm?fileName=66791.htm
    Looks like this explains it. While we're here, I don't understand exactly why Parallels decided to allow the users to configure scheduled tasks with a restricted shell, that shell being unusable anyway? Why would you offer access to an unusable feature?
  14. KrisScott

    KrisScott New Member

    Messages:
    33
    burnleyvic, you are a god!

    Cron is working now. Thankyou so much for helping this novice.

    Who would have guessed we had to unlock shell access for crontab from the command prompt even after we've given the accounts full shell access in the account setup.

    Thanks again. Your time, patience, and advice has been gratefully received and very much appreciated. Hope that one day I can repay your kindness.

    Kris
  15. partywolf

    partywolf New Member

    Messages:
    19
    Thank you! Thank you! Thank you! Thank you! Thank you!
  16. Blade5

    Blade5 New Member

    Messages:
    2
    Works

    This works for me.

    I was pointed to http://kb.parallels.com/en/115842 to add new programs to a chrooted shell environment

    and tried all there is to get the scheduled task to work but couldn't.

    wget, php, lynx... none of them worked with error like :command not found or :error not found

    REM-ed out SHELL... in /var/spool/cron/testuser and it worked straight away!

    THANK YOU SO MUCH

Share This Page