Hello,
I need to retrieve the latest log filename from remote host. I was trying to do following:
==
@task
@roles('RemoteHosts')
def RetrieveFile():
TmpFile = (sorted(glob.glob('/opt/tomcat/logs/catalina.*'), key=os.path.getmtime))[-1]
print TmpFile==
Apparently, this doesn't work as array from glob.glob is always empty. My workaround is following:
==
@task
@roles('RemoteHosts')
def RetrieveFile():
TmpFile= run('ls -ct1 /opt/tomcat/logs/catalina.* | head -1')
print TmpFile
==
It is working fine. But I wonder whether there is other/better solution.
Cheers,
carl