InMotion Hosting Support Center

Cron job permission denied

Category: Cpanel

BradCraw
Asked:
2014-03-27 6:32 pm EST

Hits: 3,837
I set up a cron job in Cpanel according to instructions from my CMS software but received this email alert:
/usr/local/cpanel/bin/jailshell: /usr/bin/wget: Permission denied

The cron I tried to run was:
wget --tries=1 --timeout=99999 -0 cron.txt http://www.example.com

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by User

1

JacobIMH
9,968 Points
2014-03-27 6:47 pm EST
Hello BradCraw, and thanks for your question.

If you are trying to <a href="http://www.inmotionhosting.com/support/edu/cpanel/301-run-cron-job" target="_blank">run a cron job</a> on shared hosting, it's important to note that <strong>wget</strong> is disabled for security reasons.

You can instead utilize <strong>curl</strong> if you need to download a remote file, being sure to also define a user-agent so that it doesn't trip a ModSecurity error:

<p class="code_block" style="width: 100%; white-space: nowrap; margin-bottom: -30px;">/usr/bin/curl --user-agent CronJob --retry 1 --max-time 60 -o cron.txt http://example.com</p>

Please let us know if you're still having any issues at all.

- Jacob

You must login before you can post a comment about this answer.

Thanks Jacob. I'll give it a shot. I copied everything you had exactly up to the URL so we'll see what happens. Would be nice if there was a way to run it now instead of having to wait for the scheduled time. Oh well. I'll report back tomorrow around noon. :-)
BradCraw
14 Points
2014-03-27 6:57 pm EST
<div style="background-color: #FFF; padding-left: 10px;">Hello BradCraw,

No problem at all. If you'd like to test out the script right away instead of waiting for the cron job to run. You could simply place this code in a file called something like <span style="color: red;">crontest.php</span>

<pre class="code_block" style="width: 100%; white-space: normal; margin-bottom: -30px;">&lt;?php

exec ("/usr/bin/curl --user-agent CronJob --retry 1 --max-time 60 -o cron.txt http://example.com");

?&gt</pre>

Then you would just access that PHP script on your site like <span style="color: red;">example.com/crontest.php</span>. If you didn't receive any errors, then you should be able to access the output file at <span style="color: red;">example.com/cron.txt</span> with the results of the remote file grab.

Please let us know if you had any other questions at all.

- Jacob</div>
JacobIMH
9,968 Points
2014-03-27 7:42 pm EST
Thanks again Jacob. I received this error report this morning when it ran:
curl: Remote file name has no length!
curl: try 'curl --help' for more information

curl: (60) error setting certificate verify locations:
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none

Do I need to do something special since my site has SSL? I think I'm just going to upgrade to VPS account for this and other reasons. But thought I would post this for anyone else with problems.
BradCraw
14 Points
2014-03-28 3:34 pm EST
<div style="background-color: #FFF; padding-left: 10px;">Hello again BradCraw,

It looks like you just left over the syntax for <strong>wget</strong> using <span style="color: red;">-O cron.txt</span> which isn't a command in <strong>curl</strong>. You instead want to use a lowercase <span style="color: red;">-o cron.txt</span>.

I've gone ahead and made this adjustment in your cron job for you.

Also it doesn't look like there is anything at the URL you are trying to request from, you'll want to make sure that there is actual content at the URL you're trying to have <strong>curl</strong> request from, otherwise you won't end up with any output in your <span style="color: red;">cron.txt</span> file.

Connecting to a site with an SSL certificate shouldn't matter, I believe you were just getting the SSL error because it didn't understand the <span style="color: red;">-O</span> flag you were passing to the command.

Please let us know if you're still having any issues at all.

- Jacob</div>
JacobIMH
9,968 Points
2014-03-28 3:55 pm EST
It worked. I tested it using the PHP exec method you gave me and after you changed the capitol O to lowercase, it ran without error. I logged into my CMS and it does show that it ran with no errors. There must be some sort of redirect because the folder the cron.txt file is supposed to be located in doesn't even exist. But it works so I'll happy. Thanks Jacob. You've been very helpful.
BradCraw
14 Points
2014-03-28 4:14 pm EST
Hello again BradCraw,

Glad to hear that's working now! When you specify the output file as just <span style="color: red;">-o cron.txt</span> in your cron job. This file should be placed in your main home directory at <span style="color: red;">/home/userna5/cron.txt</span>.

You could also enter in a full path if you wanted it to be available from your website like <span style="color: red;">-o /home/userna5/public_html/cron.txt</span> which you could then access from <span style="color: red;">example.com/cron.txt</span>.

Please let us know if you had any other questions at all!

- Jacob
JacobIMH
9,968 Points
2014-03-28 5:03 pm EST
Like this Question?

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!