-   Linux - Server (
-   -   Backups with Crontab & tar (

waynevnc 04-15-2009 02: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.

stress_junkie 04-15-2009 03: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 03:46 PM

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


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


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

waynevnc 04-16-2009 02: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

grepmasterd 04-16-2009 05: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')


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 05:45 PM

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


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

waynevnc 04-16-2009 08: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 08:31 PM

Not necessarily.


ps aux | grep postfix


ps aux | grep sendmail

to see if either of those is running.

waynevnc 04-16-2009 08: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 08:59 PM

Try ps aux | grep master

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

waynevnc 04-16-2009 09: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 11: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 11: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-17-2009 12:16 AM

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-17-2009 12:49 AM

It's Ubuntu 8.04 LTS btw

All times are GMT -5. The time now is 03:56 AM.