0

I'm very new to Cron first time using it so not really sure what I'm doing wrong. Right now I have a script called getTable1.php and basically I want to run it every 24 hours. So I went ahead and made a cron file with crontable -e and in it I wrote. 0 0 * * * /var/www/html/horario/getTable1.php. I've made sure that the file has rwx-rw--rw- so that it has permissions to execute. However when I check if the php file was executed I get the following error:

From root@CentOSTest.localdomain  Mon Aug 12 15:25:01 2019
Return-Path: <root@CentOSTest.localdomain>
X-Original-To: root
Delivered-To: root@CentOSTest.localdomain
Received: by CentOSTest.localdomain (Postfix, from userid 0)
    id 5E0E4625E8D8; Mon, 12 Aug 2019 15:25:01 -0500 (EST)
From: "(Cron Daemon)" <root@CentOSTest.localdomain>
To: root@CentOSTest.localdomain
Subject: Cron <root@CentOSTest> /var/www/html/horario/getTable1.php
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=35380>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <LANG=en_US.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20190812202501.5E0E4625E8D8@CentOSTest.localdomain>
Date: Mon, 12 Aug 2019 15:25:01 -0500 (EST)

/bin/sh: /var/www/html/horario/getTable1.php: /usr/bin/php^M: bad 
interpreter: No such file or directory

Thank you in advance!

  • 2
    Possible duplicate of [Crontab unable to execute PHP script. bad interpreter: No such file or directory](https://stackoverflow.com/questions/47385103/crontab-unable-to-execute-php-script-bad-interpreter-no-such-file-or-directory) – aynber Aug 12 '19 at 20:44
  • 1
    Mixing Windows and Linux new lines? `/usr/bin/php^M` get rid of that `^M` in your .php shebang – brombeer Aug 12 '19 at 20:45

0 Answers0