Skip to content

Instantly share code, notes, and snippets.

@sbryans
Created January 12, 2024 12:26
Show Gist options
  • Save sbryans/7817d740ef7fa6819ee92bd596fdc81d to your computer and use it in GitHub Desktop.
Save sbryans/7817d740ef7fa6819ee92bd596fdc81d to your computer and use it in GitHub Desktop.
Here's how to get notified in Discord when a Linux process finishes.
#!/bin/bash
WEBHOOK="https://discord.com/api/webhooks/"
# Replace yes process with your process
PID=`ps aux |grep yes |grep -v grep |awk '{print $2}'`
while [ "$PID" != "" ]
do
# Replace yes process with your process
PID=`ps aux |grep yes |grep -v grep |awk '{print $2}'`
echo "$PID: Active"
sleep 2
done
# Notify Discord when finished.
curl -H "Content-Type: application/json" -d '{"content": "Process Finished."}' $WEBHOOK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment