[wplug] script help
Tim Quinlan
tim at techfocus.net
Fri Oct 31 17:49:24 EST 2003
Make a script something like this, chmod 700 it for root and run the
script from root's cron (not the individual commands). Whenever you use
su in a script, always use the dash, it changes the environment
variables to that user
#!/bin/sh
cp -Ruf /home /mnt/windows/backup/
su - postgres
pg_dumpall > /mnt/windows/backup/file.sql
exit
su - whoever
somecommand
exit
exit
On Fri, 2003-10-31 at 08:51, Russ Schneider wrote:
> I have 2 hard drives on my machine. One for linux, the other for windows.
>
> Usually all I use the windows drive for is to back up files from my
> linux drive.
>
> I'd like to write a script and cron it so that it would run these
> commands for copying the files every week or so in the middle of the
> night, but some of the commands need to be run under different users.
> Such as:
>
> cp -Ruf /home /mnt/windows/backup/ (needs to be run as root)
> pg_dumpall > /mnt/windows/backup/file.sql (needs to be run as postgres)
>
> et cetera....
>
> If I were to write a simple BASH script to run these commands, how could
> I get the commands to run as particular users?
>
>
> (Note: I don't know if there's a password for user postgres, I just su
> postgres from root.)
>
More information about the wplug
mailing list