Need help about cron jobs.

RSA_ASR

Registered
Aug 19, 2007
1
0
51
Hello there.


I need help with one cron job. I need change every 2 or 3 hours one file. I try explain:


I have 3 files:

config.php
config2.php
config3.php

I need rename every file each 2 hours

config.php => config2.php
config2.php => config3.php
config3.php => config.php


I don't know how can I make it... if only its possible make with 2 files, then no problem, but I need something like this, and I think this is the way to rename files.. :)
 

rentaserv.net

Registered
Aug 19, 2007
4
0
51
Config File

Hi,

I believe You Would Have To Make A Main Configuration File to Make these changes thn configure the cron in cpanel to run this action every hour or whatever time frame you want.
 

nerbonne

Well-Known Member
Aug 19, 2007
52
1
58
Probably better to have three configs, config1, 2, and 3. Then run a cron job every three hours to remove the old link and write a new one to config1. Have three cron jobs on three different hours.
 

DGermancp

Active Member
Feb 25, 2006
43
0
156
NJ, USA
cPanel Access Level
Reseller Owner
If you have shell access, I think what you want is

1)make a file /home/$USER/rotatephp.sh

mv config.php tmp.php
mv config3.php config.php
mv config2.php config3.php
mv tmp.php config.php

Then

export YYMMDD=`date +"%y%m%d"` #create a variable to uniquely save current crontab
crontab -l > crontab.$YYMMDD # list current crontab ( that's an ell not a eye)
cat > crontab.$YYMMDD <<++ # append what follows to crontab file
07 0,2,4,6,8,10,12,14,16,18,20,22 * * * /home/$USER/rotatephp.sh
++

crontab crontab.$YYMMDD # install new crontab

see http://www.real-world-systems.com/docs/crontab.1.html

Let us know if that's what you need or
If you do not have shell access