Hi,

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".

Thanks

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

<?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())";
    $run=mysql_query($sql);
}
?>
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

why don't you do the same in bash/perl/python ?

SOLVED.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.