tar: Removing leading `/' from member names

使用tar命令时,报错:tar: Removing leading `/' from member names

网查到,原来是因为tar打包绝对路径文件时,会做这样的警告。而且tar在实际生产的打包文件中会将绝对路径转化为相对路径:

[root@zbserver3 test]# tar -czvf etc-$(date +\%Y%m%d%M%S)  /etc/zabbix > /dev/null
tar: Removing leading `/' from member names 


[root@zbserver3 test]# tar -tvf etc-201702101553.tar.gz
drwxr-xr-x root/root         0 2017-02-03 15:44 etc/zabbix/
-rw-r--r-- root/root      7904 2016-05-04 13:37 etc/zabbix/zabbix_agentd.conf
-rw-r--r-- root/root       802 2016-05-04 13:37 etc/zabbix/zabbix_java_gateway.conf
drwxr-xr-x root/root         0 2017-02-03 15:27 etc/zabbix/zabbix_agentd.d/
-rw-r--r-- root/root      1517 2016-05-04 13:37 etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
-rw-r----- root/zabbix   13551 2017-02-03 15:43 etc/zabbix/zabbix_server.conf
drwxr-x--- apache/apache     0 2017-02-03 15:50 etc/zabbix/web/
-rw-r--r-- apache/apache   422 2017-02-03 15:50 etc/zabbix/web/zabbix.conf.php
-rw-r--r-- root/root      1036 2016-04-20 17:50 etc/zabbix/web/maintenance.inc.php      

怎么解决这个问题呢,tar可以使用-P参数打包绝对路径文件:

[root@zbserver3 test]# tar -czvPf etc-$(date +\%Y%m%d%M%S).tar.gz  /etc/zabbix > /dev/null

[root@zbserver3 test]# tar -tvf etc-201702101852.tar.gz
tar: Removing leading `/' from member names
drwxr-xr-x root/root         0 2017-02-03 15:44 /etc/zabbix/
-rw-r--r-- root/root      7904 2016-05-04 13:37 /etc/zabbix/zabbix_agentd.conf
-rw-r--r-- root/root       802 2016-05-04 13:37 /etc/zabbix/zabbix_java_gateway.conf
drwxr-xr-x root/root         0 2017-02-03 15:27 /etc/zabbix/zabbix_agentd.d/
-rw-r--r-- root/root      1517 2016-05-04 13:37 /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
-rw-r----- root/zabbix   13551 2017-02-03 15:43 /etc/zabbix/zabbix_server.conf
drwxr-x--- apache/apache     0 2017-02-03 15:50 /etc/zabbix/web/
-rw-r--r-- apache/apache   422 2017-02-03 15:50 /etc/zabbix/web/zabbix.conf.php
-rw-r--r-- root/root      1036 2016-04-20 17:50 /etc/zabbix/web/maintenance.inc.php

这样就不会再发出警告了。

参考:http://blog.csdn.net/billfeller/article/details/15107897



作者:C86guli
链接:https://www.jianshu.com/p/fb31e79891d2
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
posted @ 2018-06-11 15:52  Oops!#  阅读(712)  评论(0编辑  收藏  举报