Humayun Kabir
Humayun Kabir

Reputation: 611

cron job not working from PHP script

I have a php file push.php to send push notification. I can run this php file from browser http://myserver.com/push.php and it sends push notification properly. I want to run this push.php automatically after 10 minutes.

My server is Linux shared server from bluehost.com. php version 5.4.39. So I choose cron job feature in cpanel. I have insert my mail so when push.php run / cron works and I receive mail.

I followed https://my.bluehost.com/cgi/help/168 and set time 10 minute and command php -q /home2/applusme/public_html/pushfolder/push.php where /home2/applusme is showing beside home icon and pushfolder is folder. I received mail but push is not sending.

I tried many ways but push not sent. below is push command and what i get in mail body from Cron Daemon <[email protected]>

  1. php -q /home2/applusme/public_html/pushfolder/push.php

mail content: <script type="text/javascript">window.top.location.reload();</script>

  1. wget http://myserver.com/push.php

mail content:

`http://myserver.com/push.php
Resolving myserver.com... 62.59.23.60
Connecting to myserver.com|62.59.23.60|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: “push.php”`

3. /usr/local/php5/bin/php5 /home2/applusme/public_html/pushfolder/push.php

mail content: /usr/local/cpanel/bin/jailshell: /usr/local/php5/bin/php5: No such file or directory

  1. cd /home2/applusme/public_html/pushfolder; /usr/local/php5/bin/php5 -q push.php

mail content: /usr/local/cpanel/bin/jailshell: /usr/local/php5/bin/php5: No such file or directory

  1. curl http://myserver.com/push.php mail content:

    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
    
    0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    100    72    0    72    0     0    132      0 --:--:-- --:--:-- --:--:--   133
    
  2. php /home2/applusme/public_html/pushfolder/push.php mail:

     Set-Cookie: PHPSESSID=ds4glu5kcbtu0tg95orkn2uci7; path=/
     Expires: Thu, 19 Nov 1981 08:52:00 GMT
     Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
     Pragma: no-cache
     Content-type: text/html
    
    <script type="text/javascript">window.top.location.reload();</script>
    

I have spend more than 5 hours in this issue but no luck. Please suggest me what can I do.

Thanks in advance

Upvotes: 0

Views: 1327

Answers (1)

Humayun Kabir
Humayun Kabir

Reputation: 611

I found the problem from @jeroen help. I have included include_once('includes/dbconfig.php'); into my push.php. There was javascript code into dbconfib.php. I removed javascript code and it works fine.

Thank you all

Upvotes: 1

Related Questions