-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.py
More file actions
91 lines (57 loc) · 1.5 KB
/
background.py
File metadata and controls
91 lines (57 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
### check for running process
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 30 00:07:07 2016
@author: mas
"""
#!/usr/bin/env python3
import re
import subprocess
check="./run.sh"
def is_running(process):
s = subprocess.Popen(["ps", "axw"],stdout=subprocess.PIPE)
for x in s.stdout:
if process in x:
print("Processing is running")
# print(x)
#else:
# print("no")
print("check complete")
is_running(b"run.sh")
##############
sample run command
#!/usr/bin/bash
mas=0
run='/usr/bin/date'
rm -rf check
while [ $mas -lt 10 ] ; do
$run >> check
sleep 5
done
###
python
### run a backgroup process and send the stout to a file. Use the file for a status update and delete
### http://stackoverflow.com/questions/1996518/retrieving-the-output-of-subprocess-call
#!/usr/bin/env python3
import subprocess, os , sys
mas = "hmm"
process = "run.sh"
#os.unlink("check")
## run background process
code= subprocess.call(["./run.sh & "],shell=True)
## check if process is running
#code= subprocess.call(["tail -f check "],shell=True)
print(mas)
##### list log files and output
### To do run a process and grab the standout when running the apiscripter we will need the log number ###
##then use this log number to locate the log files and output the contents ###
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 7 04:36:15 2016
@author: mas
"""
import os
p = os.listdir('/var/log/')
for i in p:
if 'Xorg' in i:
print(i)