LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-05-2003, 08:43 AM   #1
michedlp
LQ Newbie
 
Registered: Sep 2003
Posts: 19

Rep: Reputation: 0
Su in a cronjob


Hey all,
I have a cronjob that runs every midnight that shuts down all my uml(user-mode-linux) VM's, backs them up, and starts them up again. However, i've run into a few issues!

Basically, i have the cronjob run the script as root, but i want a part of the script.. where my VM's get restarted, to run as a different user.

I tried to use su - workshop(workshop being the appropriate user)
that hung, so i tried
su - workshop -c `openvt -fvc 2 /filesystems/start.sh`
but that didn't work either(plus i have 6 uml's that i have to restart in their own tty, so for the sake of ease, i'd rather have one command to su to workshop, then quit that part)

Is this possible? am i missing a simple command?

Cheers!
Miche
 
Old 11-05-2003, 01:22 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Try doing it with 2 scripts - ie create one script called "runasuser.sh" that contains the commands to be run by hte user then use:
su - workshop -c "/path/to/runasuser.sh"

I think the problem you had was that you used backtics and not quotes.
 
Old 11-05-2003, 01:29 PM   #3
LogicG8
Member
 
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
su - workshop -c `openvt -fvc 2 /filesystems/start.sh`

try

su - workshop -c 'openvt -fvc 2 /filesystems/start.sh'

` is not the same as '
 
Old 11-06-2003, 08:30 AM   #4
michedlp
LQ Newbie
 
Registered: Sep 2003
Posts: 19

Original Poster
Rep: Reputation: 0
Ahh.. thanks.. the ' works fine.. i s'pose i'll just do it that way.

Thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob problem chadi Linux - General 5 10-10-2004 09:09 PM
cronjob help meeh Linux - General 1 03-26-2004 11:41 AM
Cronjob engnet Linux - Networking 6 03-03-2004 09:21 AM
cronjob ugob Linux - Software 0 03-03-2004 09:20 AM
cronjob FastEddy Linux - General 1 04-12-2003 09:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration