shell

Copy files and directories recursively with tar

Copying a directory tree and its contents to another filesystem using


cp -pR directory /newplace

doesn't always do the job.

Using tar instead will preserve ownership, permissions, and timestamps. This neat trick allows using tar to perform a recursive copy without creating an intermediate tar file and overcoming all cp shortcomings.

To copy all of the files and subdirectories in the current working directory to the directory /target, use:


tar cf - * | ( cd /target; tar xfp -)

The best way to execute PHP scripts from a cron job

Running PHP scripts within the cron environment can be tricky!

A common technique for executing PHP scripts from a cron job is to use a command line utility like curl or wget to execute and subsequently retrieve the output of the script. Using this method, the command in your cron job would look like this:

wget http://domain.tld/script.php

Syndicate content