编辑/etc/profile文件,结尾添加
- ###### rm prevent ######
- alias rm='echo can not use rm command
-
使用source命令生效
- source /etc/profile
-
使用mv命令代替rm命令
将需要删除的文件移动到特定的目录,比如/home/sharedir/
在.bashrc目录设置alias
- alias rmf='rm -i'
-
定时脚本
- #!/bin/sh
- ####################################################
- ####### Scheduled file deletion script #######
- ####################################################
- ## ##
- ####################################################
- ## 1. Executed every day at 1 am
- ## 2. Delete files in the /data/recycleDir/ directory
- ####################################################
- location="/data/recycleDir/"
- find $location -mtime +48 -type f |xargs rmf -f
-
使用crontab -e 定时启动del.sh脚本
- 0 1 * * * /bin/sh /data/scripts/del.sh
-
- alias shutdown=''
- alias init=''
- alias reboot=''
-
需要使用这些命令时在profile文件中去掉,source后,重新登录终端即可使用