cron execute task as different user code example
Example 1: run cron job as specific user
# Crontab Running as a Specific User
# From root's crontab sudo crontab -e, you can use:
1 1 * * * su username -c "/path/to/your/script.sh"
Example 2: run cron job as specific user
# Crontab Running as a Specifi User
# Through Command Line, you use the User's Actual crontab like this:
sudo crontab -u username -e