Can a bash script tell if it’s being run via cron?

you can try “tty” to see if it’s run by a terminal or not. that won’t tell you that it’s specifically run by cron, but you can tell if its “not a user as a prompt”.

you can also get your parent-pid and follow it up the tree to look for cron, though that’s a little heavy-handed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)