I have ubuntu 8 and want to set a crone job.

When ubuntu starts, i login as;
username: ubuntu
password: ubuntu

I open terminal an type these:

root@ubuntu:/home/ubuntu# crontab -e
*/10 * * * * /var/www/project/index.php

(to run index.php every 10 seconds) and save it and wait.

Nothing happens!!!

Do i miss anything? Do you think root@ubuntu:/home/ubuntu# is wrong?

Note : In the System>Administration>Users and Groups, there are "ubuntu" and "root" as users. Nothing else. Also, by the clock top right end side, it says "ubuntu".


9 Years
Discussion Span
Last Post by veledrom

do you have permission to run that file? also, since its a php script, it should be run from the apache+php, not straight as a command line


I can run it on Firefox (localhost/test/index.php). I change permission to root and try OR permission to ubuntu and try. Both doesn't work. This is exactly what i do.

I login to ubuntu as : username= ubuntu password= ubuntu and "ubuntu user" is shown next to clock, top right end side.

root@ubuntu:home/ubuntu# sudo gedit /var/www/test/index.php

$conn=mysql_connect("localhost", "root", "");
if (!$conn) {
    echo "err";
} else {
    mysql_select_db("mydb", $conn);

    $sql="insert into login (username, moment) values ('uuu', now())";
root@ubuntu:home/ubuntu# cron -e -u ubuntu
1 * * * * /var/www/test/index.php
root@ubuntu:home/ubuntu# cron -e
1 * * * * /var/www/test/index.php

root@ubuntu:home/ubuntu# ls -l /var/spool/cron/crontabs
-rw ---------- 1 root crontab 264 2009-03-15 13:58 root
-rw ---------- 1 root ubuntu 242 2009-03-15 13:58 root~
-rw ---------- 1 ubuntu crontab 264 2009-03-15 13:58 ubuntu


I tried to run php on the terminal. It didn't run because php5-cli wasn't installed. I have installed and changed cron to */1 * * * * /usr/bin/php /var/www/test/index.php run every 1 minute.

It works now. thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.