How to schedule a job in shellscript

In Linux based operating system we can schedule a job using cron tab but you should be a root user to configure this. We can achieve this through shell script as well, In this process we may to introduce some delay to achieve the frequency of the task.This script can be used in linux/unix/solaris operating systems. We can configure job at specific time as like below.

sh scripts.sh | at 0050 Mar 27 &

Here script.sh is the script we are scheduling at 12.50 am on 27 th March.  After started the script if you wanted to run the task every one hour . We can do as like below.

#run every 10 minutes
while true; do
// Add your task here
 sleep 10m

Now the task we defined will run in every 10 mins. Please note this job will go off if we reboot the machine.


Post a Comment

Powered by Blogger.