cron から起動する sh で、別の sh を起動するときのパス指定

cron 実行時のカレントディレクトリーは ${HOME} 。

下記のように、cron 実行ファイル test.sh は ${HOME} とは異なるディレクトリーにあるとした場合

ホームディレクトリー ${HOME}
cron 用 sh 配置ディレクトリー ${HOME}/sample-base

test.sh から同じディレクトリーにある test01.sh を呼びだす。

# test.sh

./test01.sh # 【NG】

./sample-base/test01.sh # 【OK】

${HOME}/sample-base/test01.sh # 【OK】

※ 両 sh が「sample-base」ディレクトリーにある場合。

更新日:
作成日: