TurnKey Linux Virtual Appliance Library

PHP Cronjob

k.temming's picture

I've been trying to get crontab to run a php script, but with no succes. I have tried to find php, but i cannot find the binaries. I've searched the filesystem and i tried these:


root@lamp ~# whereis php                                                                                                      
root@lamp ~# which php
root@lamp ~# 
root@lamp ~# whereis php5
php5: /etc/php5 /usr/lib/php5 /usr/share/php5 
root@lamp ~# which php5
root@lamp ~# 
All are not revealing the binarys. Where is that php binarie stored?
Jeremy Davis's picture

To run php from the command line you need php-cli

Install like this:

apt-get update && apt-get install php5-cli

EnsconcE's picture

Thanks, Now i have the


Now i have the cronjob like this:

php /var/www/pathto/file.php

Jeremy Davis's picture

You may need to use the full path for php

Like this:

/usr/bin/php /var/www/pathto/file.php

You can also run php scripts with curl and wget. See this.

Guest's picture

There is a typo in your

There is a typo in your command:


apt-get update && apt-get instal php5-cli
It should be 
apt-get update && apt-get install php5-cli
Jeremy Davis's picture

Right you are.

Thanks for that. I just fixed it...

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)