PDA

View Full Version : Scheduled Task Help


TheSupportForum
11-05-2012, 01:35 AM
Hi i need support with this scheduled task

rename("$logfile/$logname", "$logfile/backup/$logname" . date("d-M-Y", time()) . ".txt");;

the issue is as follows

1) original filename from $logname is log.txt
2) after rename it become tenhbyuu.txt04-Nov-2012.txt

so what im looking for is a solutions to do

2) renamed to tenhbyuu-04-Nov-2012.txt

the reason i am using a $logname is to allow users to choose log name, i am am still looking to keep

rename("$logfile/$logname", "$logfile/backup/$logname"

in place

kh99
11-05-2012, 12:41 PM
I'm not sure I follow completely - you want to remove the ".txt" from the middle of the name? Maybe something like:

rename("$logfile/$logname", "$logfile/backup/" . substr($logname, 0, -4) . '-' . date("d-M-Y", time()) . ".txt");

TheSupportForum
11-07-2012, 09:33 AM
I'm not sure I follow completely - you want to remove the ".txt" from the middle of the name? Maybe something like:

rename("$logfile/$logname", "$logfile/backup/" . substr($logname, -4) . '-' . date("d-M-Y", time()) . ".txt");

tried it, but nothing happened, it did not create any backup file

kh99
11-07-2012, 12:50 PM
OK, sorry, there was a mistake in the code which I've fixed above. I think it would have created a file in the backup directory with a name starting with ".txt", which would be hidden on a linux system, so if you need that file it might still be there.

TheSupportForum
11-07-2012, 12:53 PM
OK, sorry, there was a mistake in the code which I've fixed above. I think it would have created a file in the backup directory with a name starting with ".txt", which would be hidden on a linux system, so if you need that file it might still be there.

the scheduled task is designed to remove the original, which is why i noticed before it did not work, i will try the code again now and see how it goes

--------------- Added 1352296655 at 1352296655 ---------------

thank you once again kh99 :)
it works now how i want it too :)