I have the following script update_pos_databases.php (simplified version)
<?php
ini_set('display_errors', 1);
set_time_limit(0);
$db_host = 'localhost';
$db_user = 'root';
$db_password = 'PASSWORD';
$databases = array('example');
$db_host = escapeshellarg($db_host);
$db_user = escapeshellarg($db_user);
$db_password = escapeshellarg($db_password);
foreach($databases as $database)
{
echo "Running queries on $database\n***********************************\n";
system("mysql --host=$db_host --user=$db_user --password=$db_password -v -v -v $database < ../update.sql");
echo "\n\n";
}
?>
When I invoke it I do the following:
nohup php update_pos_databases.php > results.txt 2>&1 </dev/null &
Since I use the system command in the php script is there any issue when using the above command can cause if one of the system commands fails for some reason? I think what I am doing is fine; but before I deploy this change I want to know of any dangers of using system() inside a script that gets called with nohup. (I don't want the script to die for some random reason).
Also will the individual system command in the script above be blocking? I want to make sure they run 1 by 1 without all running at the same time.