Reputation: 869
I am using codeigniter to create some cronjobs I scheduled it using Task schedular in windows 7. It runs every one minute but what i see is it just popup my code in an editor and does not insert any data in my database that I mentioned in index function.
<?php
class Hello extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->database();
}
public function index() {
$this->db->query("INSERT INTO test_cron VALUES(null, 'username')");
}
}
?>
How can I really execute it so That it insert data in my database
Thanks
Upvotes: 2
Views: 5234
Reputation: 4581
IF YOU ARE USING *.NIX:
*nix command:
crontab -e -u USERNAME
If you wanna edit with nano:
env EDITOR=nano crontab -e -u USERNAME
where username is the user which will initiate the script.
If you wanna run it hourly:
01 * * * * ...
For Windows 7, as you asked:
Start => Accessories => System Tools => Task Scheduler
php
before script, in order to execute, not just open.To run script with a specified period or by date, use Triggers
tab.
And there configure the task to run you're PHP script.
Upvotes: 2
Reputation: 1217
On your server, you use the command crontab -e
, which will open an editor for you where you add the code to your crontab. To have it run every hour, change the line to:
00 * * * * /usr/local/bin/php5 $HOME/system/scripts/clean_cache.php
More details about the crontab format.
Upvotes: 0
Reputation: 5397
crontab is a linux program and you say that you are using windows 7; in windows you will have to try a similar thing with scheduled tasks
(that syntax is only for unix)
Upvotes: 1