gnome-scheduleの下のシェルスクリプトからzenity出力を取得できないのはなぜですか?

gnome-scheduleの下のシェルスクリプトからzenity出力を取得できないのはなぜですか?

私はFedora Linux 12を使用しており、まもなく最新バージョンにアップデートする予定です。これに備えて、外付けドライブにフルバックアップを入れました。 rsyncを使用してこのバックアップを最新の状態に保ちたいです。システムは以下に説明されていますhttp://webgnuru.com/linux/rsync_incremental.php

バックアップをスケジュールするには、gnome-scheduleを使用し、zenityを使用してコンピュータの画面に安心できるメッセージを出力したいと思います。

私はすべての貴重な努力をする前にこれを小規模にテストしています。ここに私のシェルスクリプトのリストがあります。アップデートは完全に機能するので、私の質問は次のとおりです。最後にzenityコマンドから出力を取得できないのはなぜですか?

#!/bin/bash
# Adapted from: http://webgnuru.com/linux/rsync_incremental.php
#  Website Backup Script
#======================================================================
# Define Variables
# Todays date in ISO-8601 format e.g. 2013-10-19:
DAY0=`date -I` 
# Yesterdays date in ISO-8601 format:
DAY1=`date -I -d "1 day ago"`
# The source directory:
SRC="/home/Harry/testrsync/bravo/"
# The target directory:
TRG="/home/Harry/testrsync/backups/$DAY0" 
# The link destination directory:
LNK="/home/Harry/testrsync/backups/$DAY1"
#The rsync options:
OPT="-avh --delete --link-dest=$LNK"
#======================================================================
#Execute the backup
rsync $OPT $SRC $TRG
#Delete old backups cyclically
# for my tests I am going to use a three day cycle
DAY4=`date -I -d "4 days ago"`
#Delete the backup from 4 days ago, if it exists
if [ -d /home/Harry/testrsync/backups/$DAY4 ]
then
rm -r /home/Harry/testrsync/backups/$DAY4
fi
zenity --info --text='Backup complete' --title="Backup Test"

ベストアンサー1

あいまいなフレーズとあいまいな参照で、2日間、気になる最後に答えを見つけました。

Gnome Scheduleのヘルプドキュメントには、次のように記録されています。

9.2. Setting DISPLAY variable for tasks that will launch once

When you are creating or modifying a task, you can define the DISPLAY 
variable in the script text box. Make the definition at the beginning of the
script.

9.3. Setting DISPLAY variable for tasks that will launch recurrently

Gnome Schedule does not support yet setting environment variables for
recurrent tasks, but it will do soon. In the meantime, you can manually create
a script that first defines DISPLAY variable and then calls the graphical
application. Finally, you can create a recurrent task to launch the script.

fred.shだから、次の内容でスクリプトファイルを作成しました。

#!/bin/sh
DISPLAY=:0.0
#home/Harry/testrsync/trial_bak.sh
testrsync/trial_bak.sh

fred.shスクリプトをスケジュールされたジョブとして使用します。質問からテスト作業スクリプトの名前をtrial_bak.sh。呼び出されたスクリプトはfred.shホームディレクトリを介して参照する必要があります。つまり、上記でコメントした行ではなく、最後の行として参照する必要があります。これで動作し、必要な情報ウィンドウが表示されます。

これは、Gnome Schedule構成の「一度実行」プレビューが機能できることを意味します。これは私にうまくいくように混乱しています(at代わりに使用できると思いましたcron)。しかし、ループで行う必要があります。テストを受けて決定します。

DISPLAY=:0.0最初は質問のスクリプトの最後の行に追加しましたが、後でこれは必要ありません。

あまりにも多くの情報があふれているので、xdpyinfo | lessどんなものを使うべきかを確認したりしました。DIPSPLAY=...less

最後に、私はそれが確定的、完全、または完全に正確であると主張することなく、私が見つけた結果を説明します。誰でも追加できる関連情報に興味があります。

おすすめ記事