Small file problem
#1

Alright so the problem is quite simple, when I restart the server, new logs are being created. Meaning that old file gets deleted and it starts creating a new one for some reason

This is the code

PHP код:
public TestLog(LogString[]) {
    new 
entry[128],YearMonthDayHourMinuteSecond;
    new 
File:SomeLogFilefopen("Logs/TestLog.log",io_append);
    
getdate(YearMonthDay);
    
gettime(HourMinuteSecond);
    
format(entrysizeof(entry), "\r\n[%02d/%02d/%d][%02d:%02d:%02d]%s",Day,Month,YearHourMinuteSecond,LogString);
    
fwrite(SomeLogFile,entry);
    
fclose(SomeLogFile);
    return 
true;

Reply
#2

This may solve your problem:
Код:
public TestLog(LogString[]) { 
    new entry[128],Year, Month, Day, Hour, Minute, Second; 
    new File:SomeLogFile= fopen("Logs/TestLog.log",io_append); 
    getdate(Year, Month, Day); 
    gettime(Hour, Minute, Second); 
    format(entry, sizeof(entry), "[%02d/%02d/%d][%02d:%02d:%02d]%s\n\r",Day,Month,Year, Hour, Minute, Second,LogString); 
    fwrite(SomeLogFile,entry); 
    fclose(SomeLogFile); 
    return true; 
}
Reply
#3

Nope that didnt help
Reply
#4

that really is a weird problem...
Are you sure the file isn't created in some other part of the script? Or even exists when the server is starting and not being deleted when it shuts down for some reason?

The code snippet you posted seems to be correct, although I don't see a reason why this should create the file on a restart/start and not each time it is called...

So I'm pretty sure you have some "creating" part in your script on some other point...
Reply
#5

The thing is, it works great on my localhost, but like when I upload it to my host it starts doing that..
Could it be something thats problem with them or such?
Reply
#6

Linux OS' are case sensitive, so that might be one cause. Also check the file permissions. The server user should have full access to the scriptfiles directory and the file itself, so make sure that the directory and the file aren't owned by "root" or any other user.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)