LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-23-2003, 04:50 PM   #1
Falafel
Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Fedora
Posts: 43

Rep: Reputation: 15
help with cron script and usb drive?


Hi all!
I have set up a red hat 9 server on my fathers job on which all the users store their files. My job now is to backup this folder (/home/documents)
with cron every night.

I have read several posts here about cron but I'm still not really sure how it works. For example which cronfile do I need to edit so that the system makes this backup no matter what user is logged in - or even if there is noone logged in(if the computer waits in the logon screen)?

My other problem is the script which should mount a usb-drive to store the backup files and then unmount it. I have really no idea how to do this and i would really appreciate if someone could help me a bit!
 
Old 11-23-2003, 05:14 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
The recommended way of handling
cron-jobs is through the usage of
crontab
(man crontab for details)

As the job will have to have
permissions to read & backup
everyones files I'd suggest running
the backup as root.

As for the mounting ...

Put the mount, the tar, and the unmount
command into the same shell-script (in
root's home?) and point cron to it.



Cheers,
Tink
 
Old 11-24-2003, 03:05 PM   #3
Falafel
Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Fedora
Posts: 43

Original Poster
Rep: Reputation: 15
thank you!
but how do I open the crontab? I tried with "crontab -e" but it didn't work....
 
Old 11-24-2003, 03:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Copy and paste the output?
I'd like to see what problem you
have with it...


Cheers,
Tink
 
Old 11-24-2003, 03:37 PM   #5
Falafel
Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Fedora
Posts: 43

Original Poster
Rep: Reputation: 15
when I type crontab -e as root some strange window pops up and I cannot type or save anything. I can open /etc/crontab though. can i use that file for making the backup?
how do I type if I want to run the job as root?

My last question: how do I make a script?

thank you m8!
 
Old 11-24-2003, 03:59 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by Falafel
when I type crontab -e as root some strange window pops up and I cannot type or save anything.
That "strange thing" is called vi, and is
Unix'/Linux' most common editor :}

By default it's in a mode that will
let you delete characters, words, lines,
to do modification press either a or i
(append or insert) ... for a full overview
try man vi :}

Quote:
I can open /etc/crontab though. can i use that file for making the backup?
how do I type if I want to run the job as root?
crontab -e always works for the currently
logged in user ...

Quote:
My last question: how do I make a script?
thank you m8!
Use your favourite editor, create a file
that starts with
#!/bin/bash
on the first line, and then type all the nifty
things you want it to do.

Then save it, then make it executable with
chmod u+x <your filename here>



Cheers,
Tink
 
Old 11-24-2003, 04:34 PM   #7
Falafel
Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Fedora
Posts: 43

Original Poster
Rep: Reputation: 15
ok thank you! But if I run crontab -e as root and add my commands, will those commands be executed even if noone is logged in? (if the computer is idle at the logon screen)


I think I will manage now! thanks!
 
Old 11-24-2003, 04:52 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
That's the whole point of cron ;)

You don't need to be logged in.
If you want to make sure that you
can tell something happened, just
redirect the output of the job to a
logfile....

1 1 * * * /usr/local/f-prot/tools/check-updates.pl >> ~/fp.up 2>&1

A less ~/fp.up and a ls -ltr fp* will
show me that it worked :} and what
time it did so ;)

Cheers,
Tink
 
Old 11-25-2003, 07:38 AM   #9
Falafel
Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Fedora
Posts: 43

Original Poster
Rep: Reputation: 15
ok thank you!
 
  


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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 08:09 AM
execute shell script when USB drive plugged in OneSeventeen Linux - Hardware 2 10-28-2005 10:27 AM
Bash Script to Detect USB drive mount status nutthick Programming 6 02-02-2005 08:17 AM
PPPD Script problem when cron-scheduling the script andresurzagasti Linux - Networking 0 11-24-2004 02:54 PM
Hotplug script for Usb drive Forced2Morph Linux - Hardware 0 10-15-2004 08:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:36 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