Viewing crontab and a backup script.

Posted: September 4, 2011. At: 2:13 PM. This was 6 years ago. Post ID: 1920
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

This is a command that will list the contents of your crontab file if you have one. You need to use the sudo command as unprivileged users are not allowed to list the contents of this folder. The best way to view the contents of your crontab file is to use the crontab -l command. The crontab -e command will allow you to edit the crontab for your user. The editor uses a buffer in /tmp and will check the syntax of the file before saving, rather like the visudo command.

# Where your crontab files are created on Debian Stable.
sudo cat /var/spool/cron/crontabs/$LOGNAME

And this is the backup script that my crontab is running. A very simple perl script that will backup a folder and its contents to a *.tgz file.

use strict;
use POSIX;
my $date = strftime "%T-%A-%d-%B-%Y-%H:%M:%S", localtime;
my $myhome=getenv("HOME"); # Your home folder.
#print "Backup beginning\n\n";
my $FILE="/mnt/mediamore/$date.tgz"; # where the output file goes.
my $TARGET="$myhome/Documents/*"; # What folder to back up.
`tar -cjPf $FILE $TARGET`;
#print "Backup Complete\n";

No comments have been made. Use this form to start the conversation :)

Leave a Reply