I have a site where I want the user to be able to download all the content of a filefolder. I have therefor made a php-script that gives the user the option to create a backupfile. As this file can be rather big (several GBs of data) I have made the script that makes the backup as a bash script that I then run through the php shell_exec command.
The bash script runs fine both directly from a putty-terminal and when called from PHP, but if the files to backup are to many the process stops without finishing when called from PHP (not when called directly).
The bash command to call the script is "bash backup_shell_zip" and the shell_exec command in the calling php-file is shell_exec("bash backup_shell_zip 2>/dev/null >/dev/null &");
I can see that the script, when it runs on the larges site for backup I have with around 12 Gb of files, takes about 12 minutes to finish when called directly from a putty-terminal. When same script is called from the php shell_exec it runs for about 2½ minute before terminating without finishing (having backupped around 3 Gb). When I run the same script from a smaller example (less than 3 Gb) it works fine, but also finishes i around 2 minuttes.
So it looks like the process (bash script) terminates even though it is not finished after a period of time (or ressource) use. Perhaps it have something to do with how the server keeps an eye on processes but I am not a "server-guy", so I hope someone can help ;-)
/Malte
PHP-script calling the Bash Script
shell_exec("bash backup_shell_zip 2>/dev/null >/dev/null &");
The Bash Script
#!/bin/bash
BACKUPFILES="files"
DEST="backup"
CHUNKSIZE="500M"
# Filename
DAY=$(date +%F-%T)
ARCHIVE="backup_files"
FILENAME="$ARCHIVE-$DAY.zip"
# Print status
echo $(date +%T)
echo "Creating backup from $BACKUPFILES to $DEST/$FILENAME"
# Create ZIP-files
zip -r -s $CHUNKSIZE $DEST/$FILENAME $BACKUPFILES
# Print status
echo $(date +%T)
echo "Finished"
set_time_limit(1200)before callingshell_exec2>/dev/null >/dev/null &so it should run in the background and not be affected by neither time_limit or ini (max_execution_time), but I have tried both without succes...