如何在 Cron 中创建变量

How to make variable in Cron

我有 cron 文件在 OS Debian 中工作,行如下:

0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &
0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &
0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &
0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &
0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &
0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &
0 0 * * * php -q /var/www/bbs/public_html/worker/get.php 'domain=someDomain' < /dev/null > /var/www/bbs/public_html/worker/log/someDomain.log &

是否可以在 cron 文件中创建一个变量并放入路径中:

/var/www/bbs/public_html/worker/

并像这样在代码中使用它:

0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &
0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &
0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &
0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &
0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &
0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &
0 0 * * * php -q $VARIABLE/get.php 'domain=someDomain' < /dev/null > $VARIABLE/log/someDomain.log &

我找到了解决办法

TESTDIR=/home/user/test

* * * * * $TESTDIR/script.sh

似乎有效。