Press "Enter" to skip to content

Tag: tar

Techy: Background Processes In PHP

From What You’re Doing Is Rather Desperate is a very nice way of running a background task in PHP. I’ve implemented compression of a .tar file in the following method using this code:


$ps=runinbackground("gzip -v $tarfile -c 1> ".$tmp."download.tar.gz 2>".$tmp."download.tar.log");
$count=0;
while (isprocessrunning($ps)) {
sendupdate(3,'overall','Compressing'.str_repeat('.',$count).$lastline);
$count++;
if ($count>8) { $count=0; }
sleep(1);
}
function runinbackground($command) {
#error_log($command);
$command="nohup $command & echo $!";
#error_log($command);
$PID=shell_exec($command);
return ($PID);
}
function isprocessrunning($PID) {
exec("ps $PID",$processstate);
return(count($processstate)>=2);
}

I can then monitor (within the loop) the download.tar.log file if necessary. Hope it helps someone else.

Techy: Dealing with .tar.gz, .gz and .zip files on a cPanel Server

Many of you with cPanel web hosting accounts would have needed to upload files to a cPanel server which were in .tar.gz, .gz or .zip files (these are compressed archives).

And I bet many of you would like to have been able to upload the archives to the server “as is” (to save decompressing them on your machine and then having to slowly upload each and every file).

But did you know there is actually a “cheat” for this?

Just upload the files to your webspace via FTP (or via the cPanel File Manager) as per usual. Then login to your cPanel control panel and select “File Manager” (if you are running on the new x3 theme with cPanel 11, it doesn’t matter if you select “File Manager” or “Legacy File Manager”). Select the archive you uploaded, and then click “Decompress” from the top menu (on the new file manager) or “Extract from Archive” from the right hand menu (on the old file manager) and there you go.

Your files are now decompressed on the server quickly and simply!