Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.mac.system > #78373
| From | Jolly Roger <jollyroger@pobox.com> |
|---|---|
| Newsgroups | comp.sys.mac.system |
| Subject | Re: cron as root |
| Date | 2015-08-03 13:29 +0000 |
| Organization | People for the Ethical Treatment of Pirates |
| Message-ID | <d298lhFjn67U1@mid.individual.net> (permalink) |
| References | <1m8jveg.26jjio2tnj4yN%csampson@inetworld.net> |
On 2015-08-03, Charles H. Sampson <csampson@inetworld.net> wrote: > There appears to be something I need to know about running cron as root. > I have a bash script that's ready to go. Its first line is > > #! /bin/bash Typically there's no space between the hash bang and the path, but this should work. > I used chmod 755 on it. I can run it manually as an ordinary user. > However, I can't run it as root. The only way I can run it as root is by > using > > source scriptfile. > > Typing just > > scriptfile > > results in the line > > -sh: scriptfile: command not found I notice you didn't specify the path to the script file in your commands above. If the path to the script is not in the PATH environment variable of root, then the system will not find the script file and will return the error above. Two ways you can solve the problem: 1. Modify root's ~/.bashrc etc to add the path to the script file to the PATH environment variable. 2. Specify the fully qualified path to the script file directly in the cron table configuration file. You will also need to ensure that the script file in question has permissions set to allow execution (see: chmod). > I've noticed that when I am logged in as root and run Terminal, the > .bashrc file doesn't get executed. Guessing again, I think that this > is because when starting Terminal as root, a new Unix process doesn't > get started; instead I am just connected to the root process that is > always running. Whether this guess is right or not, my problem > remains. How do I execute my script with cron? If you want a script to execute when a user logs in, then cron is probably not the best tool for the job. What I would do instead is modify the shell startup scripts (like ~/.bashrc etc) for the account in question to execute the script. > Thanks in advance for all helpful comments. Once before, when I asked > a question about running as root, I got many responses informing me > that I shouldn't be running as root because I had not been blessed by > some authority who would give me permission. Bullshit. That's definitely *not* the advice you were given. IIRC, you posted claiming you had enabled the root account on your computer and were logging into the GUI with the root account to run backups. Most people in the know will tell you that is generally a bad idea unless you really know the implications of what you are doing. You were told "it's always a good idea to run with as few escalated privileges as possible, because (a) it reduces the *chance* of privilege escalation accidents, and (b) it reduces the *impact* of privilege escalation accidents that do occur" and that you should use an application designed for backups and run it in a standard account rather than in the root account to reduce risk. Then you copped an attitude claiming that people were attacking your character and left in a huff. > I make no claims to being qualified as a Unix sysop. That's a start. Now work on following the advice you are given. > The Unix sysops whom I know do occasionally ask questions. To those > who feel obligated to repeat this advice, I can't stop you. It wouldn't surprised me if you completely ignored the advice you were previously given, and are still futzing around with your root account backup script. If so, you're not off to a good start. -- E-mail sent to this address may be devoured by my ravenous SPAM filter. I often ignore posts from Google. Use a real news client instead. JR
Back to comp.sys.mac.system | Previous | Next — Previous in thread | Next in thread | Find similar
cron as root csampson@inetworld.net (Charles H. Sampson) - 2015-08-02 23:46 -0700
Re: cron as root Huge <Huge@nowhere.much.invalid> - 2015-08-03 07:30 +0000
Re: cron as root Jolly Roger <jollyroger@pobox.com> - 2015-08-03 13:29 +0000
Re: cron as root Jolly Roger <jollyroger@pobox.com> - 2015-08-03 14:12 +0000
Re: cron as root csampson@inetworld.net (Charles H. Sampson) - 2015-08-09 12:29 -0700
Re: cron as root Barry Margolin <barmar@alum.mit.edu> - 2015-08-09 18:59 -0500
Re: cron as root csampson@inetworld.net (Charles H. Sampson) - 2015-08-09 23:53 -0700
Re: cron as root Barry Margolin <barmar@alum.mit.edu> - 2015-08-10 02:07 -0500
Re: cron as root csampson@inetworld.net (Charles H. Sampson) - 2015-08-10 17:44 -0700
Re: cron as root Leonard Blaisdell <leoblaisdell@sbcglobal.net> - 2015-08-10 19:39 -0700
Re: cron as root Warren Oates <warren.oates@gmail.com> - 2015-08-11 07:49 -0400
Re: cron as root Barry Margolin <barmar@alum.mit.edu> - 2015-08-03 11:11 -0400
Re: cron as root csampson@inetworld.net (Charles H. Sampson) - 2015-08-09 12:29 -0700
Re: cron as root Jolly Roger <jollyroger@pobox.com> - 2015-08-09 22:23 +0000
Re: cron as root csampson@inetworld.net (Charles H. Sampson) - 2015-08-10 00:01 -0700
csiph-web