我正在尝试从Python中的journalctl读取系统日志的最后600秒。从命令行可以看出:
~ $ journalctl --since='600 seconds ago' --no-pager -p6..6
-- Logs begin at Sat 2016-05-28 09:43:08 CEST, end at Sun 2016-05-29 10:43:30 CEST. --
May 29 10:41:57 rbian dhclient[234]: DHCPREQUEST on eth0 to 10.0.1.2 port 67
May 29 10:41:57 rbian dhclient[234]: DHCPACK from 10.0.1.2
May 29 10:41:57 rbian dhclient[234]: bound to 10.0.1.11 -- renewal in 3177 seconds.
但是,当我尝试使用子进程在python中执行此操作时,我得到了这个:
~ $ python
Python 2.7.9 (default, Mar 8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> subprocess.Popen(["journalctl", "--since", "'600 seconds ago'", "--no-pager", "-p", "6..6"], stdout=subprocess.PIPE).stdout.read()
Failed to parse timestamp: '600 seconds ago'
''
>>>
那么,那是什么呢?我错过了什么?