下面我遗漏了一些东西。我总是收到意外的文件结尾。它是什么?
function lock_inactive_accounts {
echo "Locking inactive accounts or accounts that haven't logged in during the past 35 days."
echo " "
echo "The following accounts have been locked: "
su - postgres -c "psql database" << EOF
UPDATE users SET has_locked_account = true WHERE DATE_PART('days', now() - last_successful_login) > 35;
SELECT name from users where has_locked_account = 't';
EOF
}
lock_inactive_accounts
最佳答案
我相信终止 EOF
应该位于行的开头,此处文档才能正常工作:
su - postgres -c "psql database" <<EOF
UPDATE users SET has_locked_account = true WHERE DATE_PART('days', now() - last_successful_login) > 35;
SELECT name from users where has_locked_account = 't';
EOF
关于database - postgres脚本遇到语法错误: unexpected end of file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20691529/