Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 11-05-2003, 08:43 AM   #1
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/`
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?

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

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

I think the problem you had was that you used backtics and not quotes.
Old 11-05-2003, 01:29 PM   #3
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/`


su - workshop -c 'openvt -fvc 2 /filesystems/'

` is not the same as '
Old 11-06-2003, 08:30 AM   #4
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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 > Forums > Non-*NIX Forums > Programming

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

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