Попробуйте это.
/home/rails/myapp/log
{
su rails rails
daily
missingok
compress
notifempty
rotate 12
create
delaycompress
missingok
}
Поместите его в /etc/logrotate.d/myapp
Очень небольшое пояснение. Logroatate должен быть записан в вашем $ HOME, поэтому поворот для вашего myapp.log должен выполняться как рельсы.
su rails rails
извините больше из справочной страницы
su user group Rotate log files set under this user and group instead of using default user/group (usually root). user specifies the user name used for rotation and group specifies the group used for rotation. If the user/group you specify here does not have sufficient privilege to make files with the ownership you've specified in a create instruc‐ tion, it will cause an error.
create mode owner group, create owner group Immediately after rotation (before the postrotate script is run) the log file is created (with the same name as the log file just rotated). mode specifies the mode for the log file in octal (the same as chmod(2)), owner specifies the user name who will own the log file, and group specifies the group the log file will belong to. Any of the log file attributes may be omitted, in which case those attributes for the new file will use the same val‐ ues as the original log file for the omitted attributes. This option can be disabled using the nocreate option.
Извините, я не могу лучше объяснить по-английски.
Нельзя использовать одинарные кавычки в строке с одинарными кавычками.
Вместо этого используйте двойные кавычки вокруг выражения sed
:
sed -i "s/ENCRYPTION='Y'/ENCRYPTION='N'/g"
Я сомневаюсь, что это волшебным образом расшифрует ваши данные, но по крайней мере строки в файле будут заменены так, как вы, вероятно, и предполагали.
Ваша исходная команда пыталась заменить ENCRYPTION=Y
наENCRYPTION=N
(обратите внимание на отсутствующие одинарные кавычки ). Это связано с тем, что начальная одинарная кавычка в 'Y'
заканчивает строку s/ENCRYPTION=
. Затем вы объединяете Y
без кавычек с этим, за которым следует строка /ENCRYPTION=
в одинарных кавычках, за которой следует N
без кавычек и строка /g
в одинарных кавычках.