Crontabs:
Recently, i had to download source code from the repository every day.I Need to take latest code every time when i start new task. But it takes a lot of time to get the source code and building it. When i searched i got lot of information which is very use full and helped me a lot and that actually it reduces my work. I am sharing the same thing here which makes your job easy using crontab.
usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting
user's crontab)
-s (selinux context)
| .------------- hour (0 - 23)"
| | .---------- day of month (1 - 31)"
| | | .------- month (1 - 12) OR jan,feb,mar,apr ..."
| | | | .---- day of week (0 - 6) (Sunday=0 or 7)
OR
sun,mon,tue,wed,thu,fri,sat"
| | | | |"
* * * * * user-name command to be executed"
Example 1:
First we need to create the script to run your jobs. Put all the necessary commands to fetch the source and building activity. Once the script is ready, go to the terminal and type the command :
Recently, i had to download source code from the repository every day.I Need to take latest code every time when i start new task. But it takes a lot of time to get the source code and building it. When i searched i got lot of information which is very use full and helped me a lot and that actually it reduces my work. I am sharing the same thing here which makes your job easy using crontab.
usage: crontab [-u user] file
crontab [-u user] [ -e | -l | -r ]
-e (edit user's crontab)
-l (list user's crontab)
-r (delete user's crontab)
-i (prompt before deleting
user's crontab)
-s (selinux context)
Parameters:
.---------------- minute (0 - 59)"| .------------- hour (0 - 23)"
| | .---------- day of month (1 - 31)"
| | | .------- month (1 - 12) OR jan,feb,mar,apr ..."
| | | | .---- day of week (0 - 6) (Sunday=0 or 7)
OR
sun,mon,tue,wed,thu,fri,sat"
| | | | |"
* * * * * user-name command to be executed"
Example 1:
First we need to create the script to run your jobs. Put all the necessary commands to fetch the source and building activity. Once the script is ready, go to the terminal and type the command :
crontab -e
This will open the temp file then insert the command :
32 22 * * * sh /home/WorkspaceVirat/getsrc.sh
Each parameter is explained above .After giving proper date and timing to when to execute the script (getsrc.sh), save the temp file. This will create a new job. At the given time the source code will automatically downloaded and build to your mentioned path.
If you want to see the cron jobs Type command:
crontab -l
This will display all the cron jobs that are currently running.
By default Linux server will send mail to you regarding the completed jobs that you are created using crontab.
These mails are stored in
/var/spool/mail/
0 comments: