≡ Menu

crontab command

Linux: Delete / Remove User Account

How do I remove a user's access from my server? How do I delete a user account under Linux operating systems?
[click to continue…]

FreeBSD Install vnStat: A Console-Based Network Traffic Monitor

How do I install vnStat under FreeBSD 8 operating system to keep track of my network traffic?
[click to continue…]

Linux / UNIX Restrict at / cron Usage To Authorized Users

The cron and at services are used to allow commands to be executed at a later time. How do I restrict them to selected users such as root, opt1, opt2 and so on? How do I make sure user php can run php script but cannot modify or install a new job?
[click to continue…]

Linux: List / Display All Cron Jobs

How do I view currently setup or all running cron jobs under a Linux or Unix-like operating systems?
[click to continue…]

Linux Execute Cron Job After System Reboot

I am on Red Hat Enterprise Linux server. Is there is an easy way to run script or command at boot time after fresh reboot command?
[click to continue…]

Linux / UNIX: Change Crontab Email Settings ( MAILTO )

I would like to send an email to user@example.com instead of default system root user for crond service on a Linux or Unix-like system. How do I change the email settings under crontab file on a Linux or Unix-like systems?
[click to continue…]

Linux / UNIX Crontab File Location

I login to my UNIX system as a normal user. However, I need to update my cronjob entry. But, I can't find where the crontab file is. How do I find out my crontab file location?
[click to continue…]

Run crontab (cron jobs) Every 10 Minutes

How do I run a cron job or a shell script every 10 minutes using Linux / UNIX cron service?
[click to continue…]

HP-UX UNIX: Start / Stop and Configure Cron Services

Q. I need to run a backup and other stuff everyday. How do I check and start cron service under HP-UX UNIX operating system? How do I write cron jobs?
[click to continue…]

How to backup the remote files in Linux / UNIX

Q. How do I make remote backups under Linux? I’ve CentOS 5 Linux server located in remote data center and I’d like to backup it to local or another server?

A. Both Linux / UNIX come with handy tools to make secure remote backups. You can use tool called rsync for automating remote backups of your Linux, UNIX, Windows server, Mac OS X and BSD systems. rsync is a program with many more options and uses the rsync remote-update protocol to greatly speed up file transfers when the destination file is being updated.

Task: Copy files / backup files from remote Linux server

Let us say you would like to backup files from remote server called server.nixcraft.in and directory called /home/vivek to local directory called /backup, type the command as follows on local system:
$ rsync -avz -e ssh vivek@server.nixcraft.in:/home/vivek/ /backup
You need to supply password for vivek user.

Task: Exclude files from backup

You can also skip few files from backup. Let us say you don't want to backup all C source code file, enter:
$ rsync --exclude '*.cpp' -avz -e ssh vivek@server.nixcraft.in:/home/vivek/ /backup

Task: Automatic backup using a shell script

SSH always prompts for a password. To automate process via a shell script you need to remove password using SSH key i.e. generate passphraseless keys, enter (type at local system):
$ ssh-keygen -t dsa
When asked for to enter passphrase, just press [ENTER] key twice. Now copy public key to remote server:
$ scp ~/.ssh/id_dsa.pub vivek@server.nixcraft.in:.ssh/authorized_keys
Now you can login without a password. For more information see - howto setup SSH with DSA public key authentication and RSA key authentication for password less login.

Now create a simple shell script as follows:
$ vi backup.sh
Append code:
rsync --exclude '*.cpp' --exclude '*.log' -avz -e ssh vivek@server.nixcraft.in:/home/vivek/ /backup

Setup executable permission using chmod command:
$ chmod +x backup.sh
Use cron to command to backup remote server:
$ crontab -e
Make a backup everyday:
@daily /path/to/backup.sh
Save and close the file.