"不好的变量名"在bash脚本由cron启动 [英] "bad variable name" in bash script started by cron

查看:198
本文介绍了"不好的变量名"在bash脚本由cron启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

手动运行它时,在外壳上,但是当我安装一个cronjob为在重新启动运行它,我得到坏变量名作品就好了。

 #! / bin / sh的
#/etc/init.d/duplicityCleanUp
出口PASSPHRASE = foo的
口是心非删除 - 年长,比30D --force --gio SMB://远程/档案馆/
口是心非删除-全,但正满1 --force --gio SMB://远程/档案馆/
未设置PASSPHRASE


解决方案

有是#之间的空间! / bin / sh的。我不认为这是报告的问题,但它需要固定

我猜你正在使用一个版本的Unix或Linux,其中 / bin / sh的是不是bash所以
出口的语法是错误的。

改变你的脚本说。

  PASSPHRASE = foo的
出口PASSPHRASE

看到这个答案 UNIX export命令

Works just fine when running it manually on the shell but when I setup a cronjob to run it on reboot I get "bad variable name".

#! /bin/sh
# /etc/init.d/duplicityCleanUp
export PASSPHRASE=foo
duplicity remove-older-than 30D --force --gio smb://remote/archiv/
duplicity remove-all-but-n-full 1 --force --gio smb://remote/archiv/
unset PASSPHRASE

解决方案

There is a space between the #! and the /bin/sh. I don't think this is the reported problem but it needs fixing

I guess that you are using a version of Unix or Linux where /bin/sh is not bash so the export syntax is wrong.

Alter your script to say

PASSPHRASE=foo
export PASSPHRASE

See this answer unix export command

这篇关于"不好的变量名"在bash脚本由cron启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆