Clear Cache Directory Files

In Linux we are using PHP Smarty template engine,
since the cache is created for each and every execution of PHP script,
it is hard to clear manually the tpl folder for each time in the development system.
in that case we are forced to delete the tpl files in that directory. so we need a solution so that automatically clear the cache entry.

This kind of deleting files in the given folder can be easlily done by the shell script,
Assume we have to delete cached file in Dir = /var/www/Smarty/template_c/;
Here the Bash Shell Script as follows:

For this kind of you have to write

while [ ]; do
filecnt=`ls /var/www/Smarty/template_c/ | wc -w `
"file count: $filecnt"
if [ $filecnt ]
echo "No File"
sleep 1
"File Deleting..."
rm /var/www/Smarty/template_c/*.* ;
sleep 2

Since Shell Console(terminal) is the parent process, when we close or logout the console default all child process is killed including but i want this shell script alone tot run.

For these we have to run the script similar to Daemon.For these we have to know about the init process which is the parent process of all user process.

Init process => PID= 1, PPId =0.
Process Id 0 => Kernel

Since Init is the parent process having the process ID 1 which runs forever cant die(kill) even with SIGKILL. we can make use of it.

run the script with nohup prefix. assume the shell script name is when the parent process kill signel is called automatically parent process is changed to init process.
nohup sh