Guest_imported
New member
- Jan 1, 1970
- 0
Problem: Need to run a cron job as a particular user with all environment variables and paths set up.
example: 30 1 * * * /path/to/script.sh
What I tried:
All as specific_user crontab
30 1 * * * /home/.profile; /path/to/script.sh
-Does not work. If I echo env or path in the script.sh none of my vars are there. It looks like the first command gets spawned to a separate process.
30 1 * * * /path/to/script_that_calls_profile_then_runs_script.sh
-Does not work. If I echo env or path in the script.sh none of my vars are there. It looks like the first command gets spawned to a separate process.
Set /etc/default/cron PATH=/path_I_need/
30 1 * * * /path/to/script.sh
-Does not set path (stop and restarted CRON)
Set /etc/default/cron SUPATH=/path_I_need/
30 1 * * * /path/to/script.sh
-Does not set path (stop and restarted CRON)
As root crontab
30 1 * * * su - specific_user /path/to/script.sh
That works!
I would like to put the script in the user crontab not root.
example: 30 1 * * * /path/to/script.sh
What I tried:
All as specific_user crontab
30 1 * * * /home/.profile; /path/to/script.sh
-Does not work. If I echo env or path in the script.sh none of my vars are there. It looks like the first command gets spawned to a separate process.
30 1 * * * /path/to/script_that_calls_profile_then_runs_script.sh
-Does not work. If I echo env or path in the script.sh none of my vars are there. It looks like the first command gets spawned to a separate process.
Set /etc/default/cron PATH=/path_I_need/
30 1 * * * /path/to/script.sh
-Does not set path (stop and restarted CRON)
Set /etc/default/cron SUPATH=/path_I_need/
30 1 * * * /path/to/script.sh
-Does not set path (stop and restarted CRON)
As root crontab
30 1 * * * su - specific_user /path/to/script.sh
That works!
I would like to put the script in the user crontab not root.