內核版本:Linux version 3.18.20
問題描述:為了在嵌入式開發板上實作應用程式行程開機自動啟動,撰寫了一個init.d腳本來執行應用程式,由于應用程式檔案是 ADB 工具下載到開發板的,默認是沒有可執行權限的,所以在 init.d 腳本中使用 chmod 來修改權限;
下載檔案到系統之后,重啟開發板,發現權限修改過來了,但是檔案的大小變成0了,程式也就沒法正常執行了:
-rwxr-xr-x 1 root root 0 Oct 14 08:23 yln_app
#!/bin/sh
#
# Copyright (C) 2016-2020 Quectel Wireless Co.,Ltd.
# Quectel Wireless Proprietary and Confidential.
# -----------------------------------------------
#
# Description:
# init.d script for Quectel QuecOpen application.
#
# Created by Stanely.YONG
#
#############################################################
#
set -e
# here user can indicate the user app path
AppProgram=/home/root/yln_app
case "$1" in
start)
if ! [ -f $AppProgram ]
then
echo "### QuecOpen Application doesn't exist ###"
exit 3
fi
#change file mode +x before app start
chmod 755 $AppProgram
echo -n ">>> Starting QuecOpen application: "
#start-stop-daemon -S -b -a $AppProgram
$AppProgram &
echo "done"
;;
stop)
echo -n "Stopping quectel daemon: "
start-stop-daemon -K -n AppImageBinV01
echo "done"
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: QuecOpen_startapp { start | stop | restart }" >&2
exit 1
;;
esac
exit 0
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/86234.html
標籤:應用程序開發區
上一篇:linux新手求助
