Jump to content


Photo

How to setup a cron job

cron job

  • Please log in to reply
5 replies to this topic

#1 ckuo

ckuo

    Newbie

  • Members
  • 7 posts

Posted 11 February 2020 - 03:59 PM

Hi tech support, 

 

could you help me check if I setup the cron job correctly? I don't receive any emails from the output of the scrip so I am wondering if it runs at all. 

 

I set a gmail email in the cron job panel and the cron job frequency set to once per day. The command filled with the following: 

 

/usr/local/bin/php /home/ckuo/public_html/div_radar/tools/updateStocks.php

 

 

Thanks!

Attached Files



#2 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 11,665 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 February 2020 - 05:40 PM

Your command is wrong.

 

Try this (assuming PHP 5.6 is the desired PHP version). Note that if the script doesn't produce any output, no email will be sent.

ea-php56 -q /home/ckuo/public_html/div_radar/tools/updateStocks.php 2>&1

If your script produces output but you still prefer not to receive the emails containing it:

ea-php56 -q /home/ckuo/public_html/div_radar/tools/updateStocks.php >/dev/null 2>&1

Please do not PM me for support. Posting on our forums lets all of us learn.
Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#3 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 19,492 posts
  • Gender:Male

Posted 11 February 2020 - 10:55 PM

/usr/local/bin/php /home/ckuo/public_html/div_radar/tools/updateStocks.php

/usr/local/bin/php should work and on Johnny it's php 7.2

Here's the errors your script is showing:
PHP Warning:  fopen(../../cgi-bin/div_radar_cgi/curl_log_updateStocks.txt): failed to open stream: No such file or directory in /home/ckuo/public_html/div_radar/tools/updateStocks.php on line 15
PHP Warning:  curl_setopt(): supplied argument is not a valid File-Handle resource in /home/ckuo/public_html/div_radar/tools/updateStocks.php on line 17

d1 = 2020/02/11
d7 = 2020/02/18
PHP Warning:  fclose() expects parameter 1 to be resource, bool given in /home/ckuo/public_html/div_radar/tools/updateStocks.php on line 25


#4 ckuo

ckuo

    Newbie

  • Members
  • 7 posts

Posted 14 February 2020 - 01:39 AM

Hi, 

 

I've tried the new syntax. I think the cron launches but the script doesn't work for some reason.

 

I noticed that if I run the script on the browser 

http://ckuo.heliohos...pdateStocks.php

It works perfectly, but if the cron runs it, it shows these error logs below. In both cases the script is exactly the same "updateStocks.php"

 

[14-Feb-2020 00:00:23 UTC] PHP Warning: fopen(../../cgi-bin/div_radar_cgi/curl_log_updateStocks.txt): failed to open stream: No such file or directory in /home/ckuo/public_html/div_radar/tools/updateStocks.php on line 15

 
Why isn't fopen able to read the files? 
 
Thanks!


#5 Krydos

Krydos

    Rank X Member

  • Root Admin
  • 19,492 posts
  • Gender:Male

Posted 14 February 2020 - 03:52 AM

Instead of using a relative path ../../cgi-bin use an absolute path /home/ckuo/public_html/cgi-bin.



#6 ckuo

ckuo

    Newbie

  • Members
  • 7 posts

Posted 15 February 2020 - 04:31 AM

Hi, 

 

I changed to an absolute path and it works perfectly now. Thanks a lot!







Also tagged with one or more of these keywords: cron job

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users