#!/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