💻 Software
with a shell script, it is possible to tell when it's run with cron vs run manually?
Fresh5 days ago
Mar 15, 20263672 viewsConfidence Score0%
0%
Problem
with a shell script, it is possible to tell when it's run with cron vs run manually? UPDATE: it was asked why I want to know. My cron job will be logging, and i want to be able to log if someone is executing it manually.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: with a shell script, it is possible to tell when it's run with cron vs run manually?
Low Risk
In the times that I've needed to do this, i know it's a script that I'll never redirect to a file or to a pipe. So a simple test is to check if stdout (a.k.a file descriptor 1) is a tty (which it won't be from cron). In bash: Again, warning, this is…
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix