1

pertinent parts of python script that creates/writes log files

def kill(fullpath,typ):
    #add check to assure .recycle!!!!
    if any(check for check in requiredChecks if check in fullpath) and typ=='file':
            os.remove(fullpath)
            logFile.write('file -- ' + fullpath + '\n')
    return

curDate = datetime.datetime.now()
logName = '/home/user/backupLogs/recycleBin_'+curDate.strftime('%Y-%m-%d')+'.log '
logFile = ''
if not os.path.exists(logName):
    logFile = open(logName,'w') #log file doesn't exist, create it and  open in write mode
else:
    logFile = open(logName, 'a') #log file exists, create it and open in append mode
    logFile.write(curDate.isoformat() + '\n')

kill("/some/file/path.foo","file")

logFile.close()

this script is cron executed daily by root:root. Each day's .log file is a different size, so it is successfully writing.

But I cannot view the file!

administrator@server1: sudo su
root@server1: vi /home/user/backupLogs/recycleBin_2015-06-03.log

vim just opens a blank file and at the bottom says [new file] I double and triple checked that the file does exist.

what is going on here?

dan
  • 279
  • 1
  • 4
  • 15
  • What is `ls -l ` saying? – Dominik R Jan 06 '16 at 17:54
  • ls: cannot access recycleBin_2015-06-03.log: No such file or directory – dan Jan 06 '16 at 17:59
  • ls -l | less: -rwxrwxrwx 1 administrator administrator 73279 Jun 1 2015 recycleBin_2015-06-01.log -rw-r--r-- 1 administrator administrator 299 Jun 2 2015 recycleBin_2015-06-02.log -rw-r--r-- 1 administrator administrator 28069 Jun 3 2015 recycleBin_2015-06-03.log – dan Jan 06 '16 at 18:01

1 Answers1

1

You have an extra space in the logName declaration! Add a \ to the filename to open it with vi. And get rid of that extra space in your filename declaration ;)

Edit: that's a backslash and a space

Dominik R
  • 436
  • 3
  • 8