shell – 如何在我的crontab中使用我的别名?
发布时间:2020-12-15 18:39:24 所属栏目:安全 来源:网络整理
导读:我在.profile中有一些命令,我??想从我的crontab中调用它. 例如,如果我有, alias notify-me="~/bin/notify.pl -u user1"alias notify-team="~/bin/notify.pl -u user1 user2 user3 user4 ...." 我想只是调用别名 0 11 * * * notify-team 所以如果我的.profile
我在.profile中有一些命令,我??想从我的crontab中调用它.
例如,如果我有, alias notify-me="~/bin/notify.pl -u user1" alias notify-team="~/bin/notify.pl -u user1 user2 user3 user4 ...." 我想只是调用别名 0 11 * * * notify-team 所以如果我的.profile中的列表更新,我也不必更新crontab.但是,我似乎无法在我的crontab中使用别名.有工作吗? 我尝试了建议here的建议(例如/ bin / bash -lc和脚本包装脚本).它似乎适用于脚本但不适用于别名. 有任何想法吗?
从有关别名的联机帮助页:
Note aliases are not expanded by default in non-interactive shell,and it can be enabled by setting the 'expand_aliases' shell option using shopt. 因此,在您的采购脚本开始时尝试使用shopt -s expand_aliases.这应该让你使用华纳的建议. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |