Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
宋承宪:如何添加;2小时“;至;targetour=`date--date";现在+${nextrun}+;%k`";并致函;settings.xml";每次脚本启动时?_Date_Ssh_Crontab - Fatal编程技术网

宋承宪:如何添加;2小时“;至;targetour=`date--date";现在+${nextrun}+;%k`";并致函;settings.xml";每次脚本启动时?

宋承宪:如何添加;2小时“;至;targetour=`date--date";现在+${nextrun}+;%k`";并致函;settings.xml";每次脚本启动时?,date,ssh,crontab,Date,Ssh,Crontab,在过去的两周里,大约每天3到7小时,我一直在尝试让这个脚本将正确的日期写入“settings.xml”文件。我每天都在互联网上搜索,试图找到一些例子,但运气不好 我试图做一个演示网站,发现这个脚本,我试图了解它是如何工作的。我走了每一步,看看每一步是否有效。到目前为止,97%的完整脚本可以工作,但我不明白为什么脚本的这一部分没有在每次脚本启动时添加“30分钟” 所以我的问题是: 如何使下面脚本的这一部分写入“settings.xml”文件,并在脚本启动时添加“30分钟”或“2小时” 谢谢,马克E

在过去的两周里,大约每天3到7小时,我一直在尝试让这个脚本将正确的日期写入“settings.xml”文件。我每天都在互联网上搜索,试图找到一些例子,但运气不好

我试图做一个演示网站,发现这个脚本,我试图了解它是如何工作的。我走了每一步,看看每一步是否有效。到目前为止,97%的完整脚本可以工作,但我不明白为什么脚本的这一部分没有在每次脚本启动时添加“30分钟”

所以我的问题是:
如何使下面脚本的这一部分写入“settings.xml”文件,并在脚本启动时添加“30分钟”或“2小时”

谢谢,马克E

======此处的此脚本===SSH===========================================================================================================================================================================

# How often the demo site will be refreshed?  
# You must keep in sync the crontab refresh time and this one, eg 30 minutes refresh in crontab, 30 minutes here  
# this value will be used to calculate and update the module that display a countdown  
# nextrun=1 months 2 days 3 hours 4 minute 3 sec   

nextrun="30 Minute"  

packagedestination="/home/username/public_html/demosite/"  

# This create a new file that can be checked for creation time in a dedicated Joomla! module  
function updateJoomlaModule() {  
base="${packagedestination}flashxml/countdownfx"  
file="${base}/settings.placeholder.xml";  
targetfile="${base}/settings.xml";  
if [ -f "$file" ]  
then  
nextRun=`date --date "now +${nextrun}"`  
targetYear=`date --date "now +${nextrun}" +%Y`  
targetMonth=`date --date "now +${nextrun}" +%m`  
targetDay=`date --date "now +${nextrun}" +%e`  
targetHour=`date --date "now +${nextrun}" +%k`  
targetMinute=`date --date "now +${nextrun}" +%M`  
echo "Next update $nextRun Updating file at $file"  
sed -i "s/_targetYear/${targetYear}/g;s/_targetMonth/${targetMonth}/g;s/_targetDay/${targetDay}/g;s/_targetHour/${targetHour}/g;s/_targetMinute/${targetMinute}/g" $file  
echo "Move ${file} to ${targetfile}"  
cp ${file} ${targetfile}  

echo "<html><body></body></html>" > ${base}/index.html  
else  
echo "countdownfx module not detected!";  
fi  
}  
#演示站点多长时间刷新一次?
#您必须保持crontab刷新时间与此时间同步,例如crontab中的30分钟刷新,此处为30分钟
#此值将用于计算和更新显示倒计时的模块
#下一次=1个月2天3小时4分钟3秒
nextrun=“30分钟”
packagedestination=“/home/username/public_html/demosite/”
#这将创建一个新文件,可在专用Joomla中检查创建时间!模块
函数updateJoomlamModule(){
base=“${packagedestination}flashxml/countdownfx”
file=“${base}/settings.placeholder.xml”;
targetfile=“${base}/settings.xml”;
如果[-f“$file”]
然后
nextRun=`date--date“now+${nextRun}`
targetYear=`date--date“now+${nextrun}”+%Y`
targetMonth=`date--date“now+${nextrun}”+%m`
targetDay=`date--date“now+${nextrun}”+%e`
targetour=`date--date“now+${nextrun}”+%k`
targetMinute=`date--date“now+${nextrun}”+%M`
echo“下一次更新$nextRun在$file处更新文件”
sed-i“s/_targetYear/${targetYear}/g;s/_targetMonth/${targetMonth}/g;s/_targetDay/${targetDay}/g;s/_targetHour/${targetHour}/g;s/_targetMinute/${targetMinute}/g”文件
echo“将${file}移动到${targetfile}”
cp${file}${targetfile}
echo”“>${base}/index.html
其他的
echo“未检测到countdownfx模块!”;
fi
}  

sed上的-i选项对占位符文件进行就地编辑。相反,您可以执行sed“…code…”>setting.xml并保持占位符文件不变。那么你的r脚本就可以重复了。

我明白了!我将代码更新为:targetfile=“${base}/settings.xml”cp${file}${targetfile}如果[-f“$file”],它就可以工作了!我忘了说=>谢谢现在,我正在尝试使用PHP,因为出于某种原因,它没有用SSH编写小时数。我在这个网站上寻找更多的信息,因为我不知道我在做什么或者为什么会出错。