Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Cron Jobs From PHP #1

Open
kleinric opened this issue Feb 22, 2011 · 0 comments
Open

Run Cron Jobs From PHP #1

kleinric opened this issue Feb 22, 2011 · 0 comments

Comments

@kleinric
Copy link

I have just followed these instructions:
http://www.4geeksfromnet.com/2009/04/graphical-bandwidth-monitor-for-ubuntu.html

I apologize if this is out of date. Rather than setting up a of cron job to create the data files for each interface, why not do it from a single php script and run it from either cron or index.php. Cron is probably the better option.

This feels a lot neater and requires only needs one script to be run by cron. The $data_dir obviously needs to be writable by the web server.
I'd recommend creating a file called "run.php" with the following contents:

<?php
require_once("config.php");
for($i = 0; $i < count($iface_list); $i++){
    $vnstat_bin." --dumpdb -i ".$iface_list[$i]." > ".$data_dir."/vnstat_dump_".$iface_list[$i];
}
?>

The cron service now need only run: "wget http://localhost/vnstat/run.php"

Adding
require_once('run.php');
to index.php, the system will always be showing the most up to date information and cron is not even needed. (Probably not great for production systems)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant