简体   繁体   中英

Automatically create alias in linux

I need to create script which would be ran by cron each day. Purpose of that script would be to create alias for one directory that each day has different name. The directory name changes it's name each day like 2013-11-11, 2013-12-11 etc. Actually, new directory get's created. I figured out that I can list that recent directory using

dirname=$(ls -lt --time=ctime | sed -n 3p | sed 's/^.* //' )  

This gets the name of most recent created directory.
Now, the problem is how to make alias for that directory to something like "backup". I have rsync creating backup from another server so I need to have something that I can "call" for from that server. I can't create cron for directory itself since it changes names each day. How can I create alias, each day, for most recently created directory ?

几乎...如果我正确理解了您的初始请求,则调用应该是相反的(-f强制链接,从而省去了先删除旧链接的需要):

ln -f /disk/backup/$dirname /disk/backup/test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM