LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 05: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, 06:14 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 04: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, 04:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Cheers,
Tink
 
Old 11-24-2003, 04: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, 04:59 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 05: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, 05:52 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
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, 08:38 AM   #9
Falafel
Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Fedora
Posts: 43

Original Poster
Rep: Reputation: 15
ok thank you!
 
  


Reply


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

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

All times are GMT -5. The time now is 10:23 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration