You are here:  » cronjob in directadmin

Support Forum



cronjob in directadmin

Submitted by karolisgo on Thu, 2011-12-22 14:44 in

hi,

may anyone is using directadmin, and has successfully cronjobs setuped?

I tried all ways:

/domains/example.com/public_html/scripts/; /usr/local/bin/php -f fetch.php @ALL

and

/usr/local/bin/php /domains/example.com/public_html/scripts/fetch.php @ALL

and

/usr/local/bin/php fetch.php @ALL

and

cd /usr/local/bin/curl --silent --compressed /domains/example.com/public_html/scripts/fetch.php @ALL)

But script is not initiated.. I see in log that cron was initiated, but I guess that I am using wrong command :/

Submitted by support on Thu, 2011-12-22 15:26

Hi Karolis,

The first option is almost correct but is missing the cd command from the front - have a go with;

cd /domains/example.com/public_html/scripts/; /usr/local/bin/php -f fetch.php @ALL

However, I wonder if it is missing /home/username from the front where username is your username on the system - have a go with:

cd /home/username/domains/example.com/public_html/scripts/; /usr/local/bin/php -f fetch.php @ALL

As well as /username/ don't forget to replace example.com with your domain name also. Finally; note that cron.php in palce of fetch.php @ALL will fetch all automation tool jobs and then import all in one go...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Fri, 2011-12-23 07:24

Thank you, now this one works fine:
cd /home/admin/domains/example.com/public_html/scripts;/usr/local/bin/php fetch.php @ALL

But this one doesnt work:
cd /home/admin/domains/example.com/public_html/scripts;/usr/local/bin/php import_slow.php @MODIFIED

cron.php idea is great, but it is not good for big sites. Problem is that it clear the database before import, and site is empty for hour until feeds are re-imported.

I think it would be great to start to fink about update.php, but not re-import :)

Could you please help me to automate import_slow.php with cron?

K.

Submitted by support on Fri, 2011-12-23 09:46

Hi karolis,

Because of the way import_slow.php works, it has to be requested using an HTTP method; which from the command line (cron) would require wget or curl - have a go with the following as the command:

/usr/bin/wget -t 0 -O /dev/null http://www.example.com/scripts/import_slow.php?filename=@MODIFIED

(all on one line of course)

However some versions of wget require --max-redirect=9999 instead of -t 0 so if the above only makes one request rather than following import_slow.php's redirects, try:

/usr/bin/wget --max-redirect=9999 -O
/dev/null http://www.example.com/scripts/import_slow.php?filename=@MODIFIED

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Fri, 2011-12-23 12:45

Tried in this way, cron is initiated but import was not started...

/usr/bin/wget -t 0 -O /dev/null http://www.example.com/scripts/import_slow.php?filename=@MODIFIED&password=mypassword

Submitted by support on Fri, 2011-12-23 14:02

Hi karolis,

That's almost certainly then because wget is not present in /usr/bin/. I notice from your original post that you had tried a curl verison; and curl will work fine provided that the -L parameter is used which instructs curl to follow HTTP redirection. Based on the path to curl from your original post; the following should work:

/usr/local/bin/curl -L -o /dev/null "http://www.example.com/scripts/import_slow.php?filename=@MODIFIED&password=mypassword"

Note that I've added "quotation marks" around the URL - this is important in command lines containing URLs as & will have a special meaning otherwise - I should have spotted this before and may be the only reason that the wget version isn't quite working so you might like to try that before moving to the CURL version...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Wed, 2011-12-28 09:20

Hi David,

This command starts cron job, but it does not goes sucessfully till the end.

It imports some products and stops. No dates in column "Imported" are updated. What is more, I see that pruducts were deleted before import, and imported just some of them.

If I run IMPORT ALL through admin panel, import goes successfully.

Could you please help me to solve this?

Thanks,
K.

Submitted by support on Wed, 2011-12-28 09:37

Hello Karolis,

I've just checked the cURL documentation and it looks like the maximum number of re-directs followed when using -L is 50, which may not be sufficient however it can be set to unlimited using the --max-redirs parameter with a value of -1, so have a go with:

/usr/local/bin/curl -L --max-redirs -1 -o /dev/null "http://www.example.com/scripts/import_slow.php?filename=@MODIFIED&password=mypassword"

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Wed, 2011-12-28 13:12

Thank you a lot, will test this tonight and come back with my results.

Regards,
K.

Submitted by karolisgo on Mon, 2012-01-02 13:31

Hi,

I tried your last advice, but unlucky. Cron Job wasn't started at all.

Do you have another idea, how to initiate Slow Import ?

Regards,
K.

Submitted by support on Mon, 2012-01-02 13:56

Hi K,

-1 doesn't seem to be working as expected as a value for --max-redirs however it works OK using an arbitrarily large number - have a go with:

/usr/local/bin/curl -L --max-redirs 9999 -o /dev/null "http://www.example.com/scripts/import_slow.php?filename=@MODIFIED&password=mypassword"

...which should do the trick...

Cheers,
David.
--
PriceTapestry.com

Submitted by karolisgo on Mon, 2012-01-02 14:30

Thanks a lot. Will try and come back with my results.