确定优先级并扼杀它们



我正在编写一个程序,将随机优先级、进程(及其相应的ID(生成到一个文本文件(processs.txt(中。到目前为止,我已经得到了生成随机进程的帮助,但我无法生成优先级及其ID。此外,我还必须想办法在完成后杀死它们。

echo "Generating random processes between 10 and 30"

min=10;
max=30;
range=$(($max-$min+1));
echo "these are the processes" >> processes.txt
shuf -n $range -e $(ps -Ao pid=) >> processes.txt
echo "these are the priorities">> processes.txt
shuf -n $range -e --{-20..19} >> processes.txt 

这可能有助于

seq -20 1 19 | shuf -n $range >> processes.txt

编辑:选中此项以将它们一起显示

for i in $(ps -Ao pid= | shuf -n $range)
do 
echo $i $((-20 + RANDOM % 40)) 
done

最新更新