Jump to content

Cron job -- linux


westman

Recommended Posts

Hi all,
I am looking for the right command to give to run a php file using a cron job.
I have tried the following...
 
/usr/local/cpanel/bin/jailshell: -c: /home/my_username/public_html/folder/file.php"
/usr/local/cpanel/bin/jailshell -q /home/my_username/public_html/folder/file.php"
/usr/local/bin/php -q /home/my_username/public_html/folder/file.php"
/usr/bin/php -q /home/my_username/public_html/folder/file.php"
and
/home/my_username/public_html/folder/file.php"

I get this error in an email...

/usr/local/cpanel/bin/jailshell: -c: line 0: unexpected EOF while looking for
matching `"'
/usr/local/cpanel/bin/jailshell: -c: line 1: syntax error: unexpected end of file

What command should I give to run a php file from a cron job?

My linux server info:

cPanel Version 64.0 (build 12)
Apache Version 2.4.25
PHP Version 5.6.30
Link to comment
Share on other sites

Are you running the first cron job with the colons? 

/usr/local/cpanel/bin/jailshell: -c: /home/my_username/public_html/folder/file.php"

Try removing the colons and also the double quote at the ends of the cron jobs.

  • Like 1
Link to comment
Share on other sites

Last question for cron jobs.

I have this cron job working fine...
/usr/local/cpanel/bin/jailshell -q /home/my_username/public_html/folder/file.php
and if I go to www.mysite.com/folder/file.php the code will run.

how do I only give access to this file through cron job and not give access through www.mysite.com/folder/file.php

Link to comment
Share on other sites

You can place the file.php in a directory other than the public_html directory since everything in the public_html directory is accessible by the public.

For example, you can create a folder(directory) for cron job files in your home or username directory and call the file from there for the cron job:

/usr/local/cpanel/bin/jailshell -q /home/my_username/cron_jobs/file.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...