是否可以在文件系统级别强制所有创建的文件条目都具有有效的 UTF-8 名称?我正在使用 Btrfs。
根据手册:
mount_opts=mount_option_string
Set a set of default mount options which will be used when the file
system is mounted. Unlike the bitmask-based default mount options
which can be specified with the -o option, mount_option_string is an
arbitrary string with a maximum length of 63 bytes, which is stored in
the superblock.
Run Code Online (Sandbox Code Playgroud)
如果我尝试设置单个选项,它会起作用:
$ tune2fs -E mount_opts=data=writeback /dev/sde2
tune2fs 1.43.5 (04-Aug-2017)
Setting extended default mount options to 'data=writeback'
Run Code Online (Sandbox Code Playgroud)
但如果我尝试设置多个选项,它似乎与tune2fs自己的解析机制冲突:
$ tune2fs -E mount_opts=data=writeback,noatime /dev/sde2
tune2fs 1.43.5 (04-Aug-2017)
Bad options …Run Code Online (Sandbox Code Playgroud) 我编写了这个小的 Python 脚本来对包含一些文件的目录进行每日备份(备份应该在一周后轮换)。就是这个:
$ cat /etc/cron.daily/file-store-backup.py
#!/usr/bin/python3
import datetime
import calendar
import subprocess
import os.path
def main():
origin = '/var/file-store'
today_name = calendar.day_name[datetime.date.today().weekday()]
dest = '/var/file-store-backup/' + today_name
if os.path.exists(dest):
subprocess.call(['rm', '-rf', dest])
subprocess.call(['cp', '--reflink=always', '-a', origin, dest])
subprocess.call(['touch', dest])
last = open('/var/file-store-backup/LAST', 'w')
print(today_name, file=last)
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
当我手动运行它时,它按预期工作,创建了一个以当前星期日命名的备份目录,但它不是每天运行:我将它留在 /etc/cron.daily 中 3 天,之后没有创建备份目录,服务器一直在运行。
权限是正确的:
$ ls -l /etc/cron.daily/file-store-backup.py
-rwxr-xr-x 1 root root 553 Abr 11 17:19 /etc/cron.daily/file-store-backup.py
Run Code Online (Sandbox Code Playgroud)
系统为Ubuntu Server 12.04.2 LTS,安装后cron配置没有被篡改。
为什么脚本没有运行?