daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. import datetime, commands
  3.  
  4. def cat_contents():
  5.   now = datetime.datetime.now()
  6.   day = now.date()
  7.   if now.hour == 0:
  8.     day = day - datetime.timedelta(1)
  9.     yr, mon, day, hr = day.year, day.month, day.day, 23
  10.   else:
  11.     yr, mon, day, hr = day.year, day.month, day.day, now.hour-1
  12.  
  13.   mon, day, hr = str(mon), str(day), str(hr)
  14.   mon, day, hr = mon.rjust(2, '0'), day.rjust(2, '0'), hr.rjust(2, '0')
  15.  
  16.   cmd = 'grep "%s/.../%s:%s" /home/t/apache-tomcat-6.0.20/logs/localhost_access_log.%s-%s-%s.txt > /home/t/apache-tomcat-6.0.20/logs/access.log'
  17.   cmd = cmd%(day, yr, hr, yr, mon, day,)
  18.   print cmd
  19.   commands.getstatusoutput(cmd)
  20.  
  21. if __name__ == "__main__":
  22.   cat_contents()
RAW Paste Data
Top