Posted: . At: 2:13 PM. This was 13 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.


Viewing crontab and a backup script.


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.

#!/bin/sh
 
# 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.

 
#!/usr/bin/perl
 
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";

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.