Hi kanna,
Had a few minutes available, so I just did a quick hack on this and came up with a reasonable solution, as follows:
The scan+import is done using the "scan.php" file.
Unfortunately, there's a check near the top to see if the user has an active session (normally not the case when calling "scan.php" on a commandline and/or within cron).
Furthermore, scan.php expects a parameter - $act - (in the URL) that tells the script what to do.
So I edited "scan.php" and modified the first few lines, - basically commenting out the check for the session as well as hardcoding a value for $act, so the modified "scan.php" now looks like this:
- Code: Select all
<?php
$act='rebuild';
/*
if (!file_exists('db_new.sql')) {
session_start();
if (!isset($_SESSION['login'])) {
echo 'Not logged in. <a href="login.php">Click here to login</a>.';
exit;
}
}
*/
// 0.6.1: Check that we can write to db.php:
if (file_exists('db.php')) {
[..the rest of scan.php...]
Guess what: It works.
Doing this on a command line actually performs a scan+import w.o. "intervention" (i.e.: you can run it in a terminal):
mhi@netvista:~$ cd /var/www/ampjuke
mhi@netvista:/var/www/ampjuke$ php ./scan.php
Some stuff to remember:
- You might need to 'cd' to a different directory on your box.
- You might need to enter the absolute path to php; f.ex.: /usr/local/bin/php/php
- All output is written to the screen - but can redirected to a file using: php ./scan.php > scan_report.htm (yes, scan.php outputs HTML...).
- Commenting out the session-check, will enable *anybody* to start a scan+import, so you might consider renaming scan.php to something else.
- The reason why you're supposed to be in the directory where AmpJuke is installed is just because scan.php includes the getid3-stuff one directory below relative to cwd.
...hope this makes sense.
Putting the above mentioned terminal-commands into a file, make the file executable, and inserting that into your crontab will actually make scan+import run at the intervals you specify in the crontab.
Since you asked for the option to scan+import using cron, I assume you're familiar with cron.
If you want, I can make a short FAQ-entry (in the
FAQ) describing what should be done.
//Michael.