Skip to main content

Cron jobs Failure in Plesk 10.x - Issue with execution of Scripts via Cron Task Scheduler

Cron jobs Failure in Plesk 10.x - Issue with execution of Scripts through Cron Task Scheduler

I have a php script. https://www.myserver.com/crontasks/checktask.php

I tried to run the tasks from the command line as the user that owns them. The tasks executed normally

ssh /usr/bin/php /var/www/vhosts/myserver.com/httpsdocs/crontasks/checktask.php

But it fails when set as a scheduled task from plesk panel using command path


/usr/bin/php /var/www/vhosts/myserver.com/httpsdocs/crontasks/checktask.php

I had directed the cron output to my email address (which i set to notify when the cron task is initiated) , and soon I started receiving this error in my email :

-: /usr/bin/php: No such file or directory

==========

Reason:

Plesk 10 inserts the following line into the crontab file for each users :

SHELL=/usr/local/psa/bin/chrootsh

This breaks the cron jobs, because it forces users to try to run cron tasks in a chroot wrapper or Jail. This error happens when the user is restricted to a chroot jail and the php binary doesn’t exist within that jail. You can manually remove the lines but Plesk will restore them when the job is edited. An option, is to run this command on the server:

/usr/local/psa/bin/server_pref -u -crontab-secure-shell /bin/sh

This changes the SHELL setting to a normal default value

============

From the Plesk 10.3.1 Administrator’s Guide I got this information

Given under topic  "Configuring the Server Execution of Scripts via Cron Task Scheduler (Linux Hosting)" on page 166
In previous versions of Plesk, the users who were granted the permission to schedule tasks with cron but were not allowed access to server shell, could still run scripts in the shell under which the cron was running. This allowed them to gain access to the data that could be potentially used to compromise the server. Starting from Parallels Plesk Panel 10.1, execution of cron tasks is automatically restricted to the chrooted shell environment. This is the default setting applied on clean installations of Panel 10.1 and in cases when data were migrated from other platforms or earlier Plesk versions. If you upgraded to Parallels Plesk Panel 10.1 from previous versions (including 10.0), then the chrooted shell is not automatically selected so as not to break execution of any scheduled tasks that your customers could have running.

If you trust your customers enough to allow execution of scripts in a non-chrooted environment, then you can select the required shell by issuing the following command in the console:

# /usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"

If you want to revert this setting and set again the default shell used by the system, issue the following command in the console:

# /usr/local/psa/bin/server_pref -u -crontab-secure-shell ""


=============

If your user has the chrooted shell:

then it will be

SHELL=/usr/local/psa/bin/chrootsh

so it wont allow to run the cron from /usr/bin/php

You can change the shell so that they are not chrooted. but as per above documentation this will give the user access to data outside of their directory .

============

So to fix the cron issue all you have to do is run the following command

/usr/local/psa/bin/server_pref -u -crontab-secure-shell "/bin/sh"

Now probably your cron tasks would start working.


Download and Read Plesk 10.3.1 Administrator’s Guide   ( Check content under topic  "Configuring the Server Execution of Scripts via Cron Task Scheduler (Linux Hosting)" on page 166 )

Popular posts from this blog

Strange problem occured while trying to create a CSV file using PHP Script - The file is not seen on FTP but can download using file's absolute path url

Strange problem occured while trying to create a CSV file - The file is not seen on FTP but can download using file's absolute path url Last day I came across a strange problem when I tried to create a csv file on therver using a PHP script. the script was simply writing a given content as a csv file. The file will be created runtime. What happened was, The script executed fine, file handler for new file was created and contents was wrote into the file using fwrite and it returned the number of bytes that was written.

How to get the Query string of a URL using the Javascript (JS)?

JS function get the Query string of a URL or value of each parameter using the Javascript(JS)? If you want to get your current page's url var my_url=document.location; to get the query string part of the url use like this: var my_qry_str= location.search; this will return the part of the url starting from "?" following by query string Lets assume that your current page url is http://www.crozoom.com/2013/page.html?qry1=A&qry2=B then the location.search function will return " ?qry1=A&qry2=B " to exclue "?", do like this:


Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »
Member
Search This Blog