Can't get cron job working

 
Post new topic   Reply to topic    34SP.com Forum Index // Scripting Support
View previous topic :: View next topic  
Author Message
lurkio
34SP Newbie
34SP Newbie


Joined: 14 Oct 2004
Posts: 5

PostPosted: Wed Oct 26, 2011 11:03 am    Post subject: Can't get cron job working Reply with quote
Trying to run a php script using cron (Akeeba backup of Joomla site). I am using lynx as shown here.

My cron command is:

/usr/local/bin/lynx -dump /path/to/php-file.php -profile=1

The -profile=1 argument is for the php script, but lynx interprets it as a lynx option:

lynx: Invalid Option: -profile=1

Is there a way to tell lynx to pass the argument to the php script?

Is it nesessary to use lynx, or can php (the "usual method") be used instead?

This is on a personal account.

Thanks for any help.

Tim
Back to top
View user's profile Send private message
philr
Super Member
Super Member


Joined: 05 Nov 2003
Posts: 990
Location: Exeter

PostPosted: Thu Oct 27, 2011 10:05 am    Post subject: Re: Can't get cron job working Reply with quote
lurkio wrote:
Trying to run a php script using cron (Akeeba backup of Joomla site). I am using lynx as shown here.

My cron command is:

/usr/local/bin/lynx -dump /path/to/php-file.php -profile=1

The -profile=1 argument is for the php script, but lynx interprets it as a lynx option:

lynx: Invalid Option: -profile=1

Is there a way to tell lynx to pass the argument to the php script?

Is it nesessary to use lynx, or can php (the "usual method") be used instead?

This is on a personal account.

Thanks for any help.

Tim


Lynx is a web browser. It isn't going to have much success parsing your PHP script. You need to give it a URL instead.

I have no idea what you're trying to do with this -profile command line option. It isn't recognized by Lynx or PHP. The usual technique for passing variables to PHP scripts is to place them in a query string.

This might work:
Code:
/usr/local/bin/lynx -dump http://www.tims-website.com/path/to/php-file.php?profile=1

_________________
Phil Ronan
フィリップ・ローナン
Back to top
View user's profile Send private message Visit poster's website
lurkio
34SP Newbie
34SP Newbie


Joined: 14 Oct 2004
Posts: 5

PostPosted: Thu Oct 27, 2011 6:20 pm    Post subject: Re: Can't get cron job working Reply with quote
philr wrote:

Lynx is a web browser. It isn't going to have much success parsing your PHP script. You need to give it a URL instead.

I have no idea what you're trying to do with this -profile command line option. It isn't recognized by Lynx or PHP. The usual technique for passing variables to PHP scripts is to place them in a query string.

This might work:
Code:
/usr/local/bin/lynx -dump http://www.tims-website.com/path/to/php-file.php?profile=1


Thanks for the suggestion. I'm only using lynx because that's what 34sp's example cron jobs page says to use. To be honest I had never even heard of Lynx before now.

The trouble with passing it a url as you suggest is that the script then tells me "You are not supposed to access this script from the web......"

What I really want is to be able to use php:

Code:
path/to/php /path/to/php-file/file.php -arg


This works a treat on another host I use. Can this not be done on a 34sp personal account, and if not, why not?

Cheers,
Tim
Back to top
View user's profile Send private message
philr
Super Member
Super Member


Joined: 05 Nov 2003
Posts: 990
Location: Exeter

PostPosted: Thu Oct 27, 2011 7:36 pm    Post subject: Reply with quote
You can run php directly if you know where the binary file is. Try /usr/local/bin/php

I still suspect you'll have problems with the -profile command line switch, which (as far as I know) isn't recognized by PHP. Are you perhaps trying to set an environment variable?

EDIT:
Just tried it out over here and apparently PHP isn't too fussy about command line arguments. It just copies them to $_SERVER["argv"]. So you were probably right

Code:
/usr/local/bin/php /path/to/php-file.php -profile=1

_________________
Phil Ronan
フィリップ・ローナン
Back to top
View user's profile Send private message Visit poster's website
lurkio
34SP Newbie
34SP Newbie


Joined: 14 Oct 2004
Posts: 5

PostPosted: Tue Nov 01, 2011 2:10 pm    Post subject: Reply with quote
Cheers, that works a treat. It's a shame the 34sp page of cron examples doesn't include a similar example - it would have saved me a lot of messing about! Having said that, I should have figured it out for myself.

So, for anyone else struggling with setting up a cron job to run the Akeeba backup script for backing up their Joomla! site, use the following command syntax:

Code:
/usr/local/bin/php /full/path/to/joomla/root/administrator/components/com_akeeba/backup.php -profile=n

The -profile=n argument is only necessary if you don't want to use the default backup profile.

Thanks for the pointers.

Cheers,
Tim
Back to top
View user's profile Send private message
Post new topic   Reply to topic    34SP.com Forum Index // Scripting Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Powered by phpBB © 2001, 2002 phpBB Group