shell – 如何在我的crontab中使用我的别名?

我在.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.这应该让你使用华纳的建议.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...