计划在通过 python 脚本部署的作业不附加到同一个日志文件
scheduled at jobs deployed via a python script do not append to same log file
我正在尝试通过 linux 中的 python 脚本部署多个 'at' 作业。
使用以下代码片段可以完美部署作业。
def Deploy_at():
''' This function will deploy nine "at" jobs
running at an interval of one minute to capture
swap usage '''
repeat = 1
while repeat <= 9:
c1 = 'at,now + %d min' % repeat
sched_cmd = list(c1.split(','))
command = "echo repeat >> data_minor.log"
p = Popen(sched_cmd, stdin=PIPE, stdout=PIPE)
p.communicate(command)
repeat += 1
但是实际命令 运行 通过 at jobs :
命令="echo repeat >> data_minor.log"
不会将输出记录到 data_minor.log 。相反,创建了 9 个文件,文件名为 data_minor.logmarcinDELIMITER2a97d38f.
需要了解为什么将输出记录到多个文件以及如何将输出记录到单个文件。
我的代码终于可以运行了。
我就是这样做的。
def Deploy_at():
''' This function will deploy nine "at" jobs
running at an interval of one minute to capture
swap usage '''
repeat = 1
while repeat <= 9:
c1 = 'at,now + %d min' % repeat
sched_cmd = list(c1.split(','))
command = '/usr/bin/python /home/ricky/python-test/cal_swap.py -m trigger\n'
p = Popen(sched_cmd, stdin=PIPE, stdout=PIPE)
p.communicate(command)
repeat += 1
我正在尝试通过 linux 中的 python 脚本部署多个 'at' 作业。 使用以下代码片段可以完美部署作业。
def Deploy_at():
''' This function will deploy nine "at" jobs
running at an interval of one minute to capture
swap usage '''
repeat = 1
while repeat <= 9:
c1 = 'at,now + %d min' % repeat
sched_cmd = list(c1.split(','))
command = "echo repeat >> data_minor.log"
p = Popen(sched_cmd, stdin=PIPE, stdout=PIPE)
p.communicate(command)
repeat += 1
但是实际命令 运行 通过 at jobs :
命令="echo repeat >> data_minor.log"
不会将输出记录到 data_minor.log 。相反,创建了 9 个文件,文件名为 data_minor.logmarcinDELIMITER2a97d38f.
需要了解为什么将输出记录到多个文件以及如何将输出记录到单个文件。
我的代码终于可以运行了。 我就是这样做的。
def Deploy_at():
''' This function will deploy nine "at" jobs
running at an interval of one minute to capture
swap usage '''
repeat = 1
while repeat <= 9:
c1 = 'at,now + %d min' % repeat
sched_cmd = list(c1.split(','))
command = '/usr/bin/python /home/ricky/python-test/cal_swap.py -m trigger\n'
p = Popen(sched_cmd, stdin=PIPE, stdout=PIPE)
p.communicate(command)
repeat += 1