In php what is the best way to run a script after one has finished for exmaple i have these two files.
My backup file.
<?php
require 'back-up.php';
#!/bin/php -d max_execution_time = 3600
$backup_dirs = array('../bu/');
$backup = new backupclass($backup_dirs);
$backup->backup('filesys','files/');
?>
The i have my amazon s3 upload file.
<?php
require_once('S3.php');
$s3 = new S3('S3KEY', 'S3SECRETKEY');
$baseurl = "/home/mlcreative/public_html/bu/files";
if ($handle = opendir('./files/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if ($s3->putObjectFile("files/$file", "testingmlc333", "lighthouse/$file", S3::ACL_PUBLIC_READ)) {
echo "<strong>We successfully uploaded your file.</strong>";
if (file_exists($baseurl . '/' . $file)) { unlink ($baseurl . '/' . $file); }
}else{
echo "<strong>Something went wrong while uploading your file... sorry.</strong>";
}
}
}
closedir($handle);
}
?>
Ok so at the moment i have a cron job setup to running the backup php file then an hour later run the amazon upload php file.
What i am asking is how i could combine these to script so i only have to run one cron job instead of two???
Any help please
You could make the backup (#1) script call the upload (#2) script via a URL when it is finished.
This means that, when the Backup Script finished, it triggers the Upload Script. The
protector=somethingSecretis just there to prevent it from being accidentally triggered.