commit 5937333be7d32e94ecaa5e3114fc11ba140acd8f Author: TangChao <735056338@qq.com> Date: Mon Aug 22 08:38:59 2022 +0000 first commit: some shell scripts diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39f152d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Logs/ diff --git a/autoMount.sh b/autoMount.sh new file mode 100755 index 0000000..e69de29 diff --git a/finger_daemon.sh b/finger_daemon.sh new file mode 100755 index 0000000..8ac0834 --- /dev/null +++ b/finger_daemon.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# Program: +# This script is a finger daemon of program ximeaImageRecorder and psdkProgram. It has three function: +# 1) ensure that the programs ximeaImagerRecorder and psdkProgram are runing; if not run the programs; +# 2) generate log file name based the local time and directory if not exist; +# 3) redirect the output of programs to file generated in (2); +# Usage: +# 1) crontab -e +# 2) */1 * * * * ~/tc_scripts/finger_daemon.sh +# History: +# 2021/07/13 Tangchao First release +# 2022/06/24 Tangchao Second release +# + +sleep 60s #rockpi need sleep 180s when start because if not wired lan which psdk's image transmission use don't work normal. + +echo "the current directory is " $(pwd) + + + +if [ ! -e /home/rock/programRunLog ]; then + mkdir /home/rock/programRunLog +else + echo directory "~/programRunLog" exist! +fi + + +cd /home/rock/programRunLog + +echo "the current directory is " $(pwd) + + + + +# run psdk program +if [ ! -e djiLog ]; then + mkdir djiLog +else + echo directory "djiLog" exist! +fi + +#echo "1111111111111111111111111111111111" + +#sleep 60s + +#echo "2222222222222222222222222222222222" + +bool=`ps -ef | grep psdk_demo | grep -v grep | wc -l` + +if [ $bool -eq 0 ] ; then + psdkLogFileName=$(date +%Y%m%d_%H%M_%S).dji_log + sudo /bin/echo $(/bin/date +%F_%T) >> /home/rock/programRunLog/djiLog/runtime.log + sudo /home/rock/tc_projects/Payload_SDK_V2.2.1_300tc/sample/platform/linux/manifold2/project/build/psdk_demo &> djiLog/$psdkLogFileName & + + echo "Now, start run dji program!" +else + echo "Dji program already runing!" +fi + + + +# run ximea program +if [ ! -e hyperspectralLog ]; then + mkdir hyperspectralLog +else + echo directory "hyperspectralLog" exist! +fi + + +procnum=`ps -ef | grep ximeaImageRecorder | grep -v grep | wc -l` + +if [ $procnum -eq 0 ] ; then + fileName=$(date +%Y%m%d_%H%M_%S).hyperspectral_log + + echo $fileName + + sudo /home/rock/tc_projects/ximeaImageRecorder/build/ximeaImageRecorder &> hyperspectralLog/$fileName & + + echo "Now, start run hyperspectral program!" +else + echo "HyperspectralLog program already runing!" +fi + diff --git a/finger_daemon_while.sh b/finger_daemon_while.sh new file mode 100755 index 0000000..8f27ba9 --- /dev/null +++ b/finger_daemon_while.sh @@ -0,0 +1,21 @@ +#! /bin/sh +PRO_NAME=psdk_demo + + +while true ; do + + NUM=`ps -ef | grep ${PRO_NAME} | grep -v grep |wc -l` +# echo $NUM + + if [ "${NUM}" -lt "1" ];then + echo "${PRO_NAME} was killed" + /bin/echo $(/bin/date +%F_%T) >> /home/rock/programRunLog/djiLog/runtime.log + psdkLogFileName=$(date +%Y%m%d_%H%M_%S).dji_log + sudo /home/rock/tc_projects/Payload_SDK_V2.2.1/sample/platform/linux/manifold2/project/build/psdk_demo &> /home/rock/programRunLog/djiLog/$psdkLogFileName + elif [ "${NUM}" -gt "1" ];then + echo "${PRO_NAME} is running" + fi + +done + +exit 0 diff --git a/kill_psdk.sh b/kill_psdk.sh new file mode 100755 index 0000000..09b6921 --- /dev/null +++ b/kill_psdk.sh @@ -0,0 +1,2 @@ +sleep 300s +ps -ef | grep psdk | grep -v grep | awk '{print $2}' | sudo xargs kill -9 diff --git a/kill_psdk_v2.sh b/kill_psdk_v2.sh new file mode 100755 index 0000000..90061fc --- /dev/null +++ b/kill_psdk_v2.sh @@ -0,0 +1,12 @@ +#! /bin/bash +psdkpid=$(ps -ef | grep psdk_demo | grep -v grep | awk '{print $2}') + +while true ; do + if [ $psdkpid -le 5000 ]; then + #sleep 100s + sudo kill $psdkpid + #echo $psdkpid 'xiaoyu 5000' + fi +done + +exit 0 diff --git a/usbadd.sh b/usbadd.sh new file mode 100755 index 0000000..33b9db5 --- /dev/null +++ b/usbadd.sh @@ -0,0 +1,4 @@ + +touch ~/mount.log + +# sudo mount /dev/sda1 /media/usb &> ~/mount.log diff --git a/usbremove.sh b/usbremove.sh new file mode 100755 index 0000000..30ff62e --- /dev/null +++ b/usbremove.sh @@ -0,0 +1,3 @@ + +touch ~/remove.log +# sudo umount /media/usb