As root, I can add user specific cron job by crontab -u user1 -e . There I can mention a shell script say runbackup.sh to get executed.
Since runbackup.sh script is used for many users, the script need to know the username (here user1) to do some user specific actions.
How the runbackup.sh could get the username when cron job invokes it?
Thanks,
Use “whoami” in your script runbackup.sh will shows who is excuting the shell.
Every user’s cron job will start a shell process. So Every whoami show the running users’ name.
Pls note that: All Users have permition to files mentioned in runbackup.sh.