Bash 如何在 crontab 情况下传递参数
您好,我正在尝试在 crontab 中传递参数,但我不明白为什么它不起作用。
这是我的脚本:
#!/bin/bash
echo "$1" >> /home/ferdinando/script/logfile.txt
# Everything below will go to the file 'log.out':
case "$1" in
start)
echo "$1"
exec ./run.sh
;;
stop)
echo "$1"
exec ./stop.sh
;;
status)
;;
*)
echo "Usage: $0 {start|stop}"
esac
exit 0
定时任务:
* * * * * /home/ferdinando/script/script.sh $1 >> /home/ferdinando/script/logfile.txt
基本上我无法以运行脚本 run.sh 的方式传递启动参数,我在 crontab 中使用“start”而不是“$ 1”进行了多次测试,但没有成功。
Hello i'm trying to pass parameters in my crontab but i can't understand why it doesn't work.
This is my script:
#!/bin/bash
echo "$1" >> /home/ferdinando/script/logfile.txt
# Everything below will go to the file 'log.out':
case "$1" in
start)
echo "$1"
exec ./run.sh
;;
stop)
echo "$1"
exec ./stop.sh
;;
status)
;;
*)
echo "Usage: $0 {start|stop}"
esac
exit 0
crontab:
* * * * * /home/ferdinando/script/script.sh $1 >> /home/ferdinando/script/logfile.txt
Basically I can't pass the start parameter in such a way as to run the script run.sh, I made several tests using in the crontab "start" instead of "$ 1" but without success.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论