Jump to content

Recommended Posts

Posted (edited)

Here is the command:

 

lynx -dump http://www.fsboiowa.com/admin/expire.php >> /dev/null

 

any idea what I need to check to see why this isn't running?

 

The person that is developing the site for me said that the "script does work because I just accessed it directly and it removed the listings."

 

I don't understand what he means by 'directly accessing it' but I have sent an email to him to find out.

 

Thanks.

Edited by rnmcd
Posted (edited)

I see that part/all of my problem is that the script I am using uses 'lynx' which is no longer available.

 

Access to GET, wget, and lynx has been removed from the servers as a security measure.  You would need to modify your script so it can be run without using these tools.

 

 

If a script that uses 'lynx' be re-written to do the same thing without 'lynx'?

 

Also, would there typically be an error message when using a non-supported 'lynx'?

Edited by rnmcd
Posted
The person that is developing the site for me said that the "script does work because I just accessed it directly and it removed the listings."

 

I don't understand what he means by 'directly accessing it' but I have sent an email to him to find out.

lynx is a text-based browser. What your developer is saying is that he can browse to the URL of the script from a browser on his machine (could be lynx, could be IE or Firefox) and it works as expected.

 

What you're trying to do in your cron job is basically the same thing - to open a browser and run your script in it. The problem is that on TCH servers, there is no longer any access to any command-line browsers (lynx, GET, and wget) that can be used to call your script through the web server.

 

If a script that uses 'lynx' be re-written to do the same thing without 'lynx'?

Yes, scripts can be rewritten so they do not depend on be called through a browser. There are usually some differences in the PHP environment that have to be taken into account; once they are, the script should work just fine.

 

Also, would there typically be an error message when using a non-supported 'lynx'?

There is, but the '>> /dev/null' part of your command is throwing away all output from the command, including error messages. (Note: The '>>' really should just be '>'.)

Posted
lynx is a text-based browser.  What your developer is saying is that he can browse to the URL of the script from a browser on his machine (could be lynx, could be IE or Firefox) and it works as expected.

 

What you're trying to do in your cron job is basically the same thing - to open a browser and run your script in it.  The problem is that on TCH servers, there is no longer any access to any command-line browsers (lynx, GET, and wget) that can be used to call your script through the web server.

Yes, scripts can be rewritten so they do not depend on be called through a browser.  There are usually some differences in the PHP environment that have to be taken into account; once they are, the script should work just fine.

There is, but the '>> /dev/null' part of your command is throwing away all output from the command, including error messages.  (Note: The '>>' really should just be '>'.)

 

Very Very informative! Thank you. :dance:

Posted

I talked to my developer and he isn't familiar with other methods to run a php file as a cron job.

 

So I'll have to start by asking the most basic questions here because I'm more novice than he is! :dance:

 

Since lynx is not available, will the script that I need still be run through a cron job but without opening a browser.

 

OR will a different non-cron job dependent script need to be written?

Posted

You would probably end up running your script like this in a cron job:

>php -q /home/cpanelName/public_html/admin/expire.php > /dev/null

Your script will still be run from a cron job. The above command invokes PHP directly to run your script without a browser and without calling it through the web server.

 

Whether or not you have another script written is up to you, but it's usually not necessary. You should be able to get your script to run by making at most a few changes to the script. What exactly would be required would depend on the actual code in your script, but you can see an example of one such case here. Adding about 10 lines of code was all that particular script needed to be run in a cron job without requiring lynx/GET/wget.

Posted
You would probably end up running your script like this in a cron job:

>php -q /home/cpanelName/public_html/admin/expire.php > /dev/null

Your script will still be run from a cron job.  The above command invokes PHP directly to run your script without a browser and without calling it through the web server.

So since that command doesn't open up a browser to run the script is that why I don't need a URL?

 

By the way, what directory is '/home/' ? Is that the actual directory name?

 

 

Whether or not you have another script written is up to you, but it's usually not necessary.  You should be able to get your script to run by making at most a few changes to the script.  What exactly would be required would depend on the actual code in your script, but you can see an example of one such case here. Adding about 10 lines of code was all that particular script needed to be run in a cron job without requiring lynx/GET/wget.

I would definitely prefer not to have another script written unless it is necessary, which, from your comments, doesn't sound like it is.

 

Also, is there any way to see if a cron job was executed? Does cPanel have a way to check or could there be another way?

Posted
So since that command doesn't open up a browser to run the script is that why I don't need a URL?

Partly. (Mostly?) In the above command, rather than using a URL as the location of the script (which could, in theory, be on any server, not just the server hosting your TCH account), you're telling PHP to run a script that stored on the local server's file system (disk drive).

 

By the way, what directory is '/home/'  ?  Is that the actual directory name? 

Yes, it is an actual directory name. Your account is set up in the /home/cpanelName directory on your server, where 'cpanelName' is the user name you use to log into CPanel. The subdirectories you see when you log into your account with an FTP program, or when you look at the files and directories in your account with CPanel's File Manager, are subdirectories of the /home/cpanelName directory that is the base of your hosting account.

 

Also, is there any way to see if a cron job was executed?  Does cPanel have a way to check or could there be another way?

CPanel does not offer any direct way to see if a cron job was executed. If you want some sort of notification that a cron job was run (for example, when testing your script to verify that it is indeed running and working), there's two common ways I'm aware of to do this:

 

1) Add some code to your script that will add an entry to a log file in your account each time the script is run.

 

2) Modify the cron job so that it does not have '> /dev/null' at the end, and if the script does not do so already, add an 'echo' command to your script so it produces some output. When a cron job is run, if the command produces any output, cron assumes this indication of an error and will e-mail the output text to you (to the e-mail address you've configured in the Cron Jobs applet in CPanel).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...