-1

When my crontab executes this script it's sending me an email with this output. I'm not sure what the problem is. This is the output that I'm receiving.

/bin/bash: /home/kingsms/public_html/cronsH.php: Permission denied

[screenshot]

jbrahy
  • 4,228
  • 1
  • 42
  • 54
  • 1
    What is the CRON syntax you wrote. Probably should be calling that with `php `. – user3783243 Nov 30 '18 at 17:17
  • @user3783243 not necessarily, it is totally possible the php script includes a shebang line and therefor specifying the environment – DarkMukke Nov 30 '18 at 17:36
  • I bought application for sms marketing.. there is it.. – Joy Barai Nov 30 '18 at 17:41
  • /home/kingsms/public_html/crons.php: line 1: ?php : No such file or directory /home/kingsms/public_html/crons.php: line 2: syntax error near unexpected token `'ENVIRONMENT',' /home/kingsms/public_html/crons.php: line 2: `define('ENVIRONMENT', 'production'); ' – Joy Barai Nov 30 '18 at 17:44
  • after changing permission to 0777 i am getting this error http://prntscr.com/lp2lw6 – Joy Barai Nov 30 '18 at 17:45

2 Answers2

1

Try making the file executable: chmod +x /home/kingsms/public_html/cronsH.php

DarkMukke
  • 2,469
  • 1
  • 23
  • 31
0

Bash is not the proper interpreter for your script. You'll need to execute it using PHP. The problem is that you'll need to know the location of your PHP interpreter. Most likely it's in one of these places.

/usr/bin/php
/usr/local/bin/php

You could also execute this in your cron and get the results.

/usr/bin/find / -name php -type f 

This should give you all the locations of the php executable.

Most likely it's going to be /usr/bin/php so you'll change your crontab entry to be:

/usr/bin/php /home/kingsms/public_html/cronsH.php

I've got to say, having anything executable and world writable in your public_html directory is a very large security risk but that's for another post.

BTW, another alternative is to open your script and put the interpreter directive at the top of the script like this.

#!/usr/bin/php
<?php
halfer
  • 19,824
  • 17
  • 99
  • 186
jbrahy
  • 4,228
  • 1
  • 42
  • 54
  • sh: blkid: command not found sh: blkid: command not found sh: blkid: command not found – Joy Barai Nov 30 '18 at 18:17
  • So you'll have to install a package that includes that binary. Probably util-linux-ng. Something like, "yum -y install util-linux-ng" – jbrahy Nov 30 '18 at 18:30