Raised This Month: $ Target: $400
 0% 

Get file modification time


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 08-14-2012 , 01:35   Get file modification time
Reply With Quote #1

Hi, i want to make script that cleans old logs because im controlling more than 150 game servers and have to most of them only ftp access.
How can i get the file modification time in amxx? Or may be other solution?
__________________
draft is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 08-14-2012 , 05:58   Re: Get file modification time
Reply With Quote #2

through AMXX i don't think it's posible, but with PERL it is. Here is a script i found some time ago on the internet

PHP Code:
#!/usr/bin/perl

use strict;
use 
Net::FTP;

my $host "ip";
my $dir "directory";
my $user 'username';
my $passwd "password";
my $interval 3600*24*7# 62 day
my $passive 1# my FTP server only works in PASV mode
my $DEBUG 0;

my $ftp Net::FTP->new($host,
Debug => $DEBUG,
Passive => $passive)
or die 
"Can't open $host\n";
$ftp->login($user$passwd) or die "Can't log in as $user\n";
$ftp->cwd($dir) or die "Can't chdir to $dir\n";
my @files $ftp->ls();

foreach 
my $file (@files) {
 
my $file_mdtm $ftp->mdtm($file) or die "Can't find $file in $dir\n";
 if (
time $file_mdtm >= $interval) {
 print 
"File $file is older than $interval secs: deleted\n";
 
$ftp->delete($fileunless $DEBUG;
 }

DjOptimuS is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-14-2012 , 06:29   Re: Get file modification time
Reply With Quote #3

should be possible with sockets, since ftp servers should send date modified with file list
but without using ftp server with sockets i dont think its possible (unless you create somekind of module capable of doing that)

Last edited by jimaway; 08-14-2012 at 06:31.
jimaway is offline
draft
Senior Member
Join Date: Jul 2007
Location: Russia, Saint-Petersburg
Old 08-14-2012 , 07:31   Re: Get file modification time
Reply With Quote #4

May be some PAWN script? Since AMXX uses pawn as basic language. I want to clean local logs (/amxmodx/logs/)
__________________
draft is offline
Waleed
Senior Member
Join Date: May 2012
Location: Pakistan
Old 08-14-2012 , 07:51   Re: Get file modification time
Reply With Quote #5

Why don't use PERL to clean logs.Use it as a server-side script, Let it access the directory then clean according to $interval time.It should work fine.
__________________
Working On:
  1. Gameplay 1 - 0% [PAUSED]
Waleed is offline
Send a message via Skype™ to Waleed
CS-A-Roland
Member
Join Date: Jul 2009
Old 08-14-2012 , 08:01   Re: Get file modification time
Reply With Quote #6

create a part in a webinterface where he gets all data of the server over a/the database and so also the /logs/ folder, then use php to delede all of the content in it!
So you can manage all over the www also with iphone or something else...
And there you can also create a list where you can set "delede" to on/off, intervalls and so on... realy flexible i think...
__________________
oOOOoooh it's www.Cs-Attack.de
New World of Warcraft Mod Beta 0.5(based on WC3FT 3.5)
Counterstrike 1.6 SERVER:
Server IP: 193.192.58.154:27200

CONDITION ZERO SERVER:
Server IP: 193.192.58.154:27016
CS-A-Roland is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-14-2012 , 08:17   Re: Get file modification time
Reply With Quote #7

There is no native for that, but you can, as another solution, create a small module with a new native which will return such time.
__________________
Arkshine is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 08-14-2012 , 09:06   Re: Get file modification time
Reply With Quote #8

why load the server more when you can use that tiny perl script ?
DjOptimuS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-14-2012 , 09:14   Re: Get file modification time
Reply With Quote #9

That's not a small module which will change something but I agree he should use first the perl script as first solution if he can.
__________________
Arkshine is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-14-2012 , 09:54   Re: Get file modification time
Reply With Quote #10

he said he has only ftp access to most of servers, how would you execute that perl script trough ftp? or trough amxx?
jimaway is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode