I am working on BeagleBone where i am running a shell script to run all python scripts present in /home/mandar/python_scripts/ directory and then after continuously running whether they are running or not. My script below works perfectly fine on x86 platform, its running all 25 python scripts at bootup(i added this script to crontab) and then after checking every 30 seconds each process, if any script is killed or new script is added to folder this shell script run them…no problem at all on X86 platform.
Now let me come to my favourite Embedded Linux, On BeagleBone i am using my root-file-system (i used busybox) and bootloader… Now the problem is busybox doesn’t support ps -no-header -C process_name because it doesnt support ps -C option instead it gives error :
Processing File: /home/mandar/Python_Scripts/1.py
ps: unrecognized option ‘–no-headers’
BusyBox v1.19.3 (2012-06-27 12:41:51 IST) multi-call binary.
Usage: ps [-o COL1,COL2=HEADER] [-T]
Show list of processes
-o COL1,COL2=HEADER Select columns for display
-T Show threads
and -o support:
ps: bad -o argument ‘-C’, supported arguments: user,group,comm,args,pid,ppid,pgid,etime,nice,rgroup,ruser,time,tty,vsz,stat,rss
Thats means (from what i understand from these errors) i had to change my line to ps -o comm process_name | wc -l this line works but returns different different values each time so when i run my script every 30 second all scripts started (even if they are already running).
Whats wrong in this change i made?
Is there any alternative by which i can check process status and depend on that run (killed or new processes) scripts from particular folder?
This is my script :
while [ 1 ]
for py in $myfiles
echo “Processing File: $py”
ps --no-headers -C $py1 | wc -l # this line works on x86 which returns 1 if process is running and 0 if not
ps -o comm $py1 | wc -l # this line i am using on arm platform which returns random values each time
if [ $status -eq ‘1’ ];
echo “$py is already running”