Execute Ubuntu 14.04 cronjob as non-root

cron, solved, ubuntu 14.04

Thread Tools Search this Thread
# 1  
Old 12-14-2017
Execute Ubuntu 14.04 cronjob as non-root

I have created a cronjob that successfully executes and among other thing runs aria2c to download several files and save them to a folder. However, since it executes as sudo, the downloaded folder is saved with those permissions.
Is there a way to execute the cronjob so that the downloaded folder is saved as non-root? As of right now the additional scripts can not see the download as permissions are not the same. I have tried sudo chmod 777 /path/to/scripts, but that does not seem to help. Thank you Smilie.
# 2  
Old 12-14-2017
Since the cronjob executes as root; you can simply change your cron script to change the permissions and ownership (as you please) when the script executes.
# 3  
Old 12-14-2017
Pick another user, go into

as that user. Create a new entry for the job. The user should be one with suitable permissions to run other code later on against the downloaded file. Hopefully you have a group or some special acl that can allow this.

Make sure that the script does not require advanced permissions to run. This means setting permissions on the directory-ies where the script lives, and on the destination directory tree.
This User Gave Thanks to jim mcnamara For This Post:
cmccabe (12-14-2017)
# 4  
Old 12-14-2017
I added the cron to crontab -u cmccabe -e and crontab: installing new crontab. This user has the correct permissions to run the script. Thank you Smilie.

---------- Post updated at 07:48 AM ---------- Previous update was at 07:46 AM ----------

I tried to change the ownership and group of the scripts but not thatt cron script. Should that be chmod 775? Thank you Smilie.
# 5  
Old 12-14-2017
755 will suffice - any user should be able to execute the script. Note: you need to check what files and directories the script runs against. Same problem.

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Cronjob not running on Ubuntu 14.04 cmccabe UNIX for Beginners Questions & Answers 5 01-16-2017 04:10 PM
Execute a command with root user mohtashims Shell Programming and Scripting 5 12-19-2016 09:00 AM
Cronjob for root password change. nixhead Shell Programming and Scripting 3 05-29-2014 04:59 PM
Cronjob question about root emails. aixnj AIX 12 12-10-2013 11:45 AM
Unable to execute glance from cronjob Shravani Shell Programming and Scripting 5 08-02-2013 08:18 AM
Cronjob to be execute today at 9pm coolboy98699 Shell Programming and Scripting 6 04-25-2013 07:25 AM
How to remove Ubuntu without root pw kuriosity_prime UNIX for Dummies Questions & Answers 1 09-11-2012 11:09 AM
expect telnet script execute by cronjob cssanangeles Shell Programming and Scripting 0 11-22-2011 08:26 PM
execute command when Ubuntu boots up ? eawedat Ubuntu 2 08-30-2011 12:47 PM
Execute Shell Script from CRONJOB reachravi70 Shell Programming and Scripting 1 12-19-2010 03:57 AM
How to execute cronjob running in a different machine? mridul10_crj Shell Programming and Scripting 1 09-27-2010 02:09 AM
Check a condition in cronjob to execute a sh file shanth_chandra Shell Programming and Scripting 2 02-16-2010 03:08 AM
ubuntu root JudoMan UNIX for Dummies Questions & Answers 2 05-14-2009 11:35 PM
need to have a cronjob which will execute certain scripts every hr aemunathan Shell Programming and Scripting 3 03-11-2009 02:06 PM
How to execute Ifconfig without being root??? erwang UNIX for Dummies Questions & Answers 3 04-17-2002 05:18 AM