diff --git a/lib/fluent/plugin/base.rb b/lib/fluent/plugin/base.rb
index 1846273a17..3bd8f44224 100644
--- a/lib/fluent/plugin/base.rb
+++ b/lib/fluent/plugin/base.rb
@@ -78,12 +78,15 @@ def get_lock_path(name)
 
       def acquire_worker_lock(name)
         if @fluentd_lock_dir.nil?
-          raise InvalidLockDirectory, "can't acquire lock because FLUENTD_LOCKDIR isn't set"
+          raise InvalidLockDirectory, "can't acquire lock because FLUENTD_LOCK_DIR isn't set"
         end
-        File.open(get_lock_path(name), "w") do |f|
+        lock_path = get_lock_path(name)
+        File.open(lock_path, "w") do |f|
           f.flock(File::LOCK_EX)
           yield
         end
+        # Update access time to prevent tmpwatch from deleting a lock file.
+        FileUtils.touch(lock_path);
       end
 
       def string_safe_encoding(str)
diff --git a/lib/fluent/plugin/out_file.rb b/lib/fluent/plugin/out_file.rb
index 7bf25a1b6e..f0a6642208 100644
--- a/lib/fluent/plugin/out_file.rb
+++ b/lib/fluent/plugin/out_file.rb
@@ -189,8 +189,8 @@ def configure(conf)
         @need_ruby_on_macos_workaround = true if condition.match?('', RUBY_VERSION)
       end
 
-      if @need_lock && @append && fluentd_lockdir.nil?
-        raise InvalidLockDirectory, "must set FLUENTD_LOCKDIR on multi-worker append mode"
+      if @need_lock && @append && @fluentd_lock_dir.nil?
+        raise Fluent::InvalidLockDirectory, "must set FLUENTD_LOCK_DIR on multi-worker append mode"
       end
     end