1

I googled for quite some time already, but I still can't find how to setup crontab with lampp.

I need to run a PHP script for every 15 minutes.

So, in bash:

$ sudo -i
# crontab -e

I get a nano editor... what should I type inside?

I tried * * * * */opt/lampp/path/to/script but it's not working.

Can anyone help me?

Félix Saparelli
  • 8,424
  • 6
  • 52
  • 67
Irene Ling
  • 1,881
  • 3
  • 26
  • 41
  • I would suggest to make a bash script and run that in the crontab instead. I always had problems with setting a command in crontab. You have to take into account that crontab works in a different enviroment. – Pithikos Oct 23 '11 at 23:31
  • I think that as long as you have `#!/usr/bin/php` on the first line, make the file executable, and add whatever PHP-specific stuff is needed in the body of the script (``), it should be ok. – Keith Thompson Oct 24 '11 at 01:23
  • @Pithikos Thanks for your reply , can I get some examples or steps on how to make a bash script ? I totally new in cron and I don't know much about it... – Irene Ling Oct 24 '11 at 09:19
  • @Irene Ling you just put '#! /bin/bash' as first line in a file and then add the commands you want to run. Commands are any commands you would normally put in a terminal. – Pithikos Oct 24 '11 at 14:34

2 Answers2

2

Your crontab script is

* * * * */opt/lampp/path/to/script

Maybe the reason is you don't have a space between the last '*' and the first '/'...

Try this:

* * * * * /opt/lampp/path/to/script
Luo
  • 162
  • 1
  • 12
  • 1
    That runs every minute, not every 15 minutes. Replace the first * with e.g. */15 – tripleee Oct 24 '11 at 05:03
  • @Iya Thank you so much for your reply Iya. Let's say my path is /opt/lampp/htdocs/testing.php , so I put * * * * * /opt/lampp/htdocs/testing.php , but it's still not working. – Irene Ling Oct 24 '11 at 09:20
  • @Iya or is there anything I should add in my testing.php? actually I don't know what is my php path . – Irene Ling Oct 24 '11 at 09:36
  • @Irene Ling Of course it doesn't work, because your testing.php is not an executable. You have to use `php /opt/.../testing.php` to execute the script. – Luo Oct 24 '11 at 09:46
  • @Iya Thank you Iya , I understand now and finally it works. Really thanks for your help. – Irene Ling Oct 24 '11 at 12:35
  • @tripleee Thankyou tripleee , I will replace it. – Irene Ling Oct 24 '11 at 12:36
0

You may have to use php path/to/script to run the PHP script: Ubuntu may not know how to run the script directly. You do have to have php-cli installed for that to work, too.

Félix Saparelli
  • 8,424
  • 6
  • 52
  • 67