I want to make sure a running python script was not modified accidentally by some other process (or cosmic ray, or unexpected developer update). I've heard of comparing a checksum of the script (e.g. with md5sum) against a known value stored in a write-protected file but am unsure how to get the checksum of a file that's in use.  Is the memory of the script that is being executed my actual source file?  Or is what is being executed somewhere else?Here is what I've tried so far, but don't know if my result is valid.1. Create a write-protected file containing the checksumcd ~/Developer/MyProj# Compute the md5 hash and store it in a new filemd5sum /home/username/Developer/MyProj/myscript.py > checksum# Remove the write permissions for all (user, group, and other)chmod a-w checksum# Inspect the permissions to validatels -al checksum2. Add cronjob to periodically (e.g. hourly) check the integrity of the scriptsudo crontab -e0     *     *     *     * /bin/sh /home/username/Developer/MyProj/healthcheck.shIn healthcheck.sh:#!/bin/bashs1=$(md5sum /home/username/Developer/MyProj/myscript.py)s2=$(cat /home/username/Developer/MyProj/checksum)if [ $s1=$s2 ]then  echo Script is what we think it iselse  echo Script was modified!fi
How to monitor the integrity of a script that is running?
cron;python;checksum