我正在構建一個天氣數據採集系統。我想要做的事情之一是使每15分鐘到達的衛星數據動畫化。事實上,我已經設計了一個腳本(名爲animate
),它成功將8小時的PNG圖像加入AVI視頻文件。當從終端手動運行時,運行良好。ffmpeg奇X服務器錯誤
不幸的是,從我的(如我的用戶,而不是根)crontab運行時不能這樣說。
下面是cron作業,我提到:
1,16,31,46 * * * * /home/daniella/bin/anim_all > /home/daniella/logs/anim_all.log 2>&1
anim_all
只是調用動畫爲每個不同的數據產品:
#!/bin/bash
set -x
cd /home/daniella/data/imager
rm -rf HRIT_MSG3_*.avi
animate HRIT_MSG3_CTT
animate HRIT_MSG3_IR108
animate HRIT_MSG3_VIS006
animate HRIT_MSG3_WV062
和動畫本身調用ffmpeg
。
#!/bin/bash
set -x
cd /home/daniella/data/imager
product=$1
hl="$product.8hl"
declare -i i=0
for file in $(cat $hl); do
link=$(printf "images%02d.png" $i)
ln -sf $file $link
i=$((i+1))
echo $i
done
ffmpeg -sameq -r 15 -i images%02d.png $product.avi
rm -rf images*.png
只是要清楚,.8hl文件僅僅是參考了過去8小時內數據的PNG文件路徑列表。由於每15分鐘有新的數據,這是一個32行的文本文件。最後,這是在檢查anim_all.log(在crontab中引用)文件時返回的錯誤。
+ animate HRIT_MSG3_CTT
animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
+ animate HRIT_MSG3_IR108
animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
+ animate HRIT_MSG3_VIS006
animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
+ animate HRIT_MSG3_WV062
animate: unable to open X server `' @ animate.c/AnimateImageCommand/365.
請注意,anim_all
工作正常,當從終端手動調用。這個錯誤只有在被cron調用時才存在。我會想象這與環境變量有關,但是我已經在腳本內部找到了我的.bashrc
,但沒有成功。
編輯 - 偵辦animate.c
文件本身(見完整code here),在線路365-368,還有這個:
if (display == (Display *) NULL)
ThrowAnimateException(XServerError,"UnableToOpenXServer",
XDisplayName(server_name));
(void) XSetErrorHandler(XError);
對此,我曾嘗試導出$DISPLAY
變量animate
腳本中的127.0.0.0.0,但此操作無效。
謝謝!因爲我自己鏈接到同一個文件,所以我應該着迷。我實施了這些變化,現在一切正常。:D – jhc