我遇到了一个奇怪的场景,正在困扰着我。当在后台启动脚本时,我得到两个运行的进程
我有我的背景与&
例如启动一个脚本:
[email protected]# some_script.sh &
它运行后,我做了PS -ef | grep some_script,我看到两个进程正在运行,第二个进程持续获得不同的PID,但是Parent是我开始的进程(就像父进程产生的子进程一样 - 但从未写入代码中)。 示例:
[email protected]# ps -ef | grep some_script.sh
root 4696 17882 0 13:30 pts/2 00:00:00 /bin/bash ./some_script.sh
root 4778 4696 0 13:30 pts/2 00:00:00 /bin/bash ./some_script.sh
[email protected]# ps -ef | grep some_script.sh
root 4696 17882 0 13:30 pts/2 00:00:00 /bin/bash ./some_script.sh
root 4989 4696 0 13:30 pts/2 00:00:00 /bin/bash ./some_script.sh
这里给出了什么?它似乎也搞乱了脚本的输出和功能,并且基本上使它成为一个永无止境的过程(当我在脚本中定义了启动和停止时)。
剧本: ` #! /斌/庆典
# Set Global Variables
LOGDIR="/srv/script_logs"
OUTDIR="/srv/audits"
BUCKET_LS=$OUTDIR"/LSOUT_"$i"_"$(date +%d%b%Y)".TXT"
MYCMD1="aws s3api list-objects --bucket viddler-flvs"
MYCMD2="--starting-token"
MAX_ITEMS="--max-items 10000"
MYSTARTING_TOKEN='""'
rm tokenlog.txt flv_out.txt
while [[ $MYSTARTING_TOKEN != "null" ]]
do
# First - Get the token for the next batch
CMD_PRE="$MYCMD1 $MAX_ITEMS $MYCMD2 $MYSTARTING_TOKEN"
MYSTARTING_TOKEN=($($CMD_PRE | jq -r .NextToken))
echo $MYSTARTING_TOKEN >> tokenlog.txt
# Now - get the values of the files for the existing batch
# First - re-run the batch and get the file values we want
MYOUT2=$($CMD_PRE | (jq ".Contents[] | {Key, Size, LastModified,StorageClass }"))
echo $MYOUT2 | sed 's/[{},"]//g;s/ /\n/g;s/StorageClass://g;s/LastModified://g;s/Size://g;s/Key://g;s/^ *//g;s/ *$//g' >> flv_out.txt
#echo $STARTING_TOKEN
done
`
你的脚本是怎么看的? – devnull
我需要看到some_script.sh中的代码才能解决这个问题。 – Donovan
“工作”报告是什么? – cdarke