Jump to content

Php Script As Cron Job?


Recommended Posts

Guest schussat
Posted

I'm not sure if "scripting talk" is quite the right place for this one, but I'll try anyway. I'd like to use this php script to automatically update my movabletype comment spam blacklist from the master list hosted by the author of mt-blacklist. The script seems to work when I execute it via the web, but its ideal use is as a cron job.

 

Not thinking through it quite completely, I simply added the script as a cron job to run at midnight, and received the following email from the cron daemon when it attempted to run the script:

 

mt-blacklist-autoupdate.php: line 1: ?php: No such file or directory

mt-blacklist-autoupdate.php: line 2: /aquota.user: Permission denied

mt-blacklist-autoupdate.php: line 4: mt-blacklist-autoupdate: command not found

mt-blacklist-autoupdate.php: line 5: syntax error near unexpected token `newline'

mt-blacklist-autoupdate.php: line 5: `Author: Gene Wood <gene_wood@***.net>'

 

I don't think there's any personally-compromising info in that excerpt; I trimmed the script's path, just in case... But it really just consists of the errors that cron gets when it tries to execute the script, line by line, as if it were a shell script -- my bad, it's PHP! Doh! I should have realized that it wouldn't work.

 

So, if I change the cron command to "php /path/to/mt-blacklist-autoupdate.php" will it work correctly?

Posted

Pretty sure that's the trick: if you start the cron job with "php" and then follow it with the absolute path to the script, you're in good shape.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...