LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Backups with Crontab & tar (https://www.linuxquestions.org/questions/linux-server-73/backups-with-crontab-and-tar-719357/)

waynevnc 04-15-2009 01:55 PM

Backups with Crontab & tar
 
I need some help with doing backups on a Ubuntu 8.04 LTS server. I have created a cron job that does not want to run. What am I doing wrong? Something simple am sure.
The crontab looks like this: 20 11 * * 4 tar -cWPpf /dev/st0 /home/public $

I know the command works cause I can run it from the command line OK but, I do have to use root. I tried using the sudo command in the crontab but, that did not work either.

Any help or suggestions would be appreciated.
Thanks
Wayne

stress_junkie 04-15-2009 02:11 PM

Cron jobs do not run the login scripts so your usual shell environment is not available. You may have to use the full path to the commands that you want to run such as using /bin/tar instead of just tar.

grepmasterd 04-15-2009 02:46 PM

use MAILTO to view the output, to see what it may be complaining about

MAILTO=me@localhost

if it's a path issue, you can update your crontab with PATH:

PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin

see `man 5 crontab` for usage of cron environment variables.

waynevnc 04-16-2009 01:49 PM

D'oh I figured it out.
1. I had the wrong day code Thursday and should have been Wednesday &
2. more importantly I needed to create the crontab with root (sudo) not a normal user.

Another question for grepmasterd. This server is just for file servering and not a gateway. Should I still have an email service going? Maybe just for error reports & admin reasons?

Thanks in advance
Wayne

grepmasterd 04-16-2009 04:41 PM

most distros will at least have mail configured for local delivery (ie, not over the network). Just use the 'mail' command line utility to access your local messages. see 'man mail' for details.

To test sending a message (assuming your login is 'wayne')

Code:

mail -s test -c root wayne
type some message using stdin here....
to end the message type Ctrl-D, or if your a SMTP traditionalist
just type a period as the first and only character in the line
like this:
.

The message should be sent to /var/mail/wayne (or wherever your system's mailboxes are). Then use 'mail' with no options to read your inbox.

billymayday 04-16-2009 04:45 PM

It may be simpler to add an alias redirecting mail from that server to another mail account, something like

root: myuser@myaccount.net

Ho to do this will depend on the MTA you have running.

waynevnc 04-16-2009 07:14 PM

I tried the command:
mail -s test -c root wayne
and got the following: the program 'mail' can be found in the following packages:
* mailx
* mailutils

I'm assuming I don't have a mail service running. What mail service would be easy to setup?

billymayday 04-16-2009 07:31 PM

Not necessarily.

Try

ps aux | grep postfix

and

ps aux | grep sendmail

to see if either of those is running.

waynevnc 04-16-2009 07:42 PM

with the ps aux|grep postfix I got:
wayne 5490 0.0 0.0 3004 752 tty1 R+ 17:37 0.00 grep postfix
&
with the ps aux|grep sendmail
wayne 5493 0.0 0.0 3004 760 tty1 S+ 17:37 0.00 grep sendmail

billymayday 04-16-2009 07:59 PM

Try ps aux | grep master

Postfix is the default mta for Ubuntu, so it probably isn't running.

waynevnc 04-16-2009 08:21 PM

pretty much the same output as for sendmail.

I guess I'll read up on installing and setting up postfix.

grepmasterd 04-16-2009 10:43 PM

no, don't bother with postfix or sendmail unless you want to send mail over the network. especially since there are plenty of security issues associated with email servers.

just use mailx. from the end of the mailx man page:

"Usually, Mail and mailx are just links to mail, which can be confusing."

Edit: oh and by the way, 'pidof sendmail' is the way to see if an instance of sendmail is running. don't bother piping ps output to grep.

billymayday 04-16-2009 10:47 PM

Shouldn't really be any security problem with Postfix - not open relay out of the box, and he doesn't even need to allow port 25 in from outside for outgoing only.

grepmasterd 04-16-2009 11:16 PM

ok, my bad. you need an mta for local delivery too (mailx does not include that). but I think exim is the default mta for debian woody. whatever is the default mta should be handling local delivery.

ah, this thread is digressing...

billymayday 04-16-2009 11:49 PM

It's Ubuntu 8.04 LTS btw

waynevnc 04-16-2009 11:54 PM

So guys you are confusing me.

What I would like to do is have email send to my outside of the network email address so I can remotely monitor administrative things on the server such as errors with backups or log files.

Shall I just setup postfix or sendmail to send mail outgoing but not receive mail? Or use mailx which I'm not familiar with?

billymayday 04-17-2009 12:06 AM

See if you already have postfix on the system (you could just use "find / -type f -name postfix". It should return an executable in /usr/sbin or similar if it's installed. If so, just fire it up (can't recall how to start services in Ubuntu -, maybe /etc/init.d/postfix start"?). It probably works at a basic level out of the box.

Otherwise, install with apt or apt-get.

grepmasterd 04-17-2009 12:19 AM

sorry for the confusion.

I use mailx to verify local delivery first. it's a good place to start. then try setting up the mta for remote delivery (which can be trickier, like when dealing with your ISP).

waynevnc 04-17-2009 09:21 AM

Ok, guys you are confusing me.

What I really want to do is receive email to an outside the network address to give me admin monitoring of things like errors on the backups or log file tracking.

Should I just use postfix or sendmail & set it up to send mail and not receive incoming messages? Or maybe use mailx which I'm not familiar with.

Yes, it is Ubuntu 8.04 LTS.

waynevnc 04-17-2009 12:28 PM

Sorry for the last post I mistakenly sent it again.

So I'm going to look into postfix.

Thanks for the help


All times are GMT -5. The time now is 08:15 PM.