下面是我的Crontab:
*/5 * * * * /usr/bin/wget "http://localhost:8080/sample/index.jsp" --post-data "data=$(nohup sqoop import --connect 'jdbc:sqlserver://localhost;username=username;password=password;database=database' --table table1 --target-dir /user/data/ -m 1)&dt=$(date)&user=$USER"
我正在安排,但它没有运行
答案 0 :(得分:1)
你必须在crontab中使用完整路径,因为它没有与你的shell相同的$ PATH值(即使用nohup,sqoop的完整路径)
答案 1 :(得分:0)
这可能是因为你不在同一个执行环境中。根据您正在运行的shell(调整我的旧学校.kshrc
),您可能需要在命令前添加source /home/myuser/.kshrc
,如下所示:
*/5 * * * * source /home/myuser/.kshrc ; /usr/bin/wget "http://localhost:8080/sample/index.jsp" --post-data "data=$(nohup sqoop import --connect 'jdbc:sqlserver://localhost;username=username;password=password;database=database' --table table1 --target-dir /user/data/ -m 1)&dt=$(date)&user=$USER"
如果可以的话,如果您的命令可以嵌入到一个小脚本中,那么每个人看起来也会更简单。如果脚本为nohup
,这可以避免这可能会误导您mycommand.sh
......
*/5 * * * * source /home/myuser/.kshrc ; /home/myuser/mycommand.sh
(给你做chmod u+x /home/myuser/mycommand.sh
授予执行权)。