[英]Batch or script file to close program with a command then reopen it
我正在我的機器上運行Minecraft服務器,發現我需要每天關閉一次並重新啟動服務器。 我正在嘗試編寫一個腳本文件,該腳本文件將把kill命令提供給服務器,並在30秒后重啟它。
腳本可能像
minecraft-start & # change the cmd, keep the '&'
PID=$!;
echo $PID > /tmp/minecraft.pid # store PID, removed if physical server reboot
sleep 24h; # wait 24 hours
kill $(cat /tmp/minecraft.pid) # kill, what about active users and all?
正如其他人提到的那樣,這可能是一項計划任務。
$!
包含最后一個命令進程ID ( 又名 PID)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.