如何在shell脚本中用当前日期创建新目录?

时间:2019-12-19 13:28:59

标签: shell jenkins

我想用当前日期创建一个新目录。我无法创建目录。请为此提出一个解决方案

export currentDate=$(date +%d-%b-%Y)
cd /mnt/volume-blr1-01/Jenkins/workspace/WebHook_Log_Backup/
sudo mkdir /mnt/volume-blr1-01/Jenkins/workspace/WebHook_Log_Backup/$currentDate

我已参考以下链接,但无法创建目录

https://linuxize.com/post/how-to-create-directories-in-linux-with-the-mkdir-command/ https://unix.stackexchange.com/questions/73978/using-root-to-mkdir-in-another-users-home-directory https://askubuntu.com/questions/716599/how-to-create-a-new-folder-from-a-terminal-with-administrative-permissions

1 个答案:

答案 0 :(得分:0)

如果要创建Jenkins Job或Pipeline,则必须使用jenkins cli(例如:https://www.youtube.com/watch?v=VBTzB9Kdx58)。创建作业时,请在变量中添加带有日期的名称,作业将带有时间戳记