Back to Resources
Level
Script
General
Critical files can sometimes be moved, deleted, or corrupted without notice, leading to system failures or unexpected behavior. This script eliminates guesswork by automatically confirming whether a file is present, helping IT Professionals and MSPs catch and fix issues before they escalate.
This script verifies if a file, specified through a Level Script Variable, exists on a Linux system. When the file is present, the script echoes a confirmation message; otherwise, it reports that the file is missing. The straightforward design makes it a reliable building block for your monitoring strategies.
You can configure a script-based monitor in Level to run this check on-demand whenever a particular event occurs, such as critical system actions or scheduled maintenance. Alternatively, you can create an Automation in Level with a schedule trigger to run this script regularly, ensuring continuous oversight of essential files.
1#!/bin/bash
2
3# This resource is provided as a convenience for Level users. We cannot
4# guarantee it will work in all environments. Please test before deploying
5# to your production environment. We welcome contributions to our community
6# library
7
8# Level Library
9# https://level.io/library/script-linux-monitor-file-exists
10
11# Specify the file path to check for existence
12file_path="{{FilePath}}"
13# -----------------------------------------------------------------------------
14
15# Check if the file exists
16if [ -f "$file_path" ]; then
17 echo "file exists: $file_path"
18else
19 echo "file not found: $file_path"
20fi
21
Linux Monitor - File Exists
This script checks for the existence of a specified file on a Linux system, outputting "file exists" or "file not found" to help monitor critical files as part of a recurring check.
Bash
100
Local system
Explore more automations, scripts, and policies to further enhance your IT operations.