Wants to change shell script into crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wants to change shell script into crontab
# 1  
Old 02-24-2012
Bug Wants to change shell script into crontab

Hi friends,

Actually i wrote many scripts in korn shell for time saving activity in storage domain. But every week i am spending some time for the running of script. So every Monday i wants to run my scripts automatically. So corn will be helpful according to my friend's opinion.
But I don't know how to change my script into corn.
Can anyone help me please?

Below is one of my sample script, can anyone same to corn.

Code:
#! /bin/ksh

if [[ $# < 1 ]];then
   clear

  read sid?"Enter last four digits of the SYMM frame:"

else
   sid=$1
fi

sudo symdev -sid $sid list -noport -nobcv >> /home/gopalpa/no_port1.$sid

cat /home/gopalpa/no_port1.$sid|awk '$1 != "Symmetrix"' >>/home/gopalpa/no_port2.$sid

cat /home/gopalpa/no_port2.$sid|awk '$NF != 3' >>/home/gopalpa/no_port3.$sid

cat /home/gopalpa/no_port3.$sid|awk '{tot+=$NF;print " Dev "$1" Dev size "$NF}END {print "Total capacity of unmapped devices  " tot " MegaBytes"}' >> /home/gopalpa/no_port.$sid

echo "unmaped devices --> cat /home/gopalpa/no_port.xxxx"

echo "Checking capacity of no_port devices in symm $sid.... /n"
cat /home/gopalpa/no_port.$sid| sed '$!d'

rm /home/gopalpa/no_port3.$sid
rm /home/gopalpa/no_port2.$sid
rm /home/gopalpa/no_port1.$sid
rm /home/gopalpa/no_port.$sid


Last edited by Franklin52; 02-24-2012 at 06:45 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 02-24-2012
1. Is your script working now as is "without changing to cron"?
2. Crontab contains entries which defines when a command or script should run. Usually this is defined in "/etc/crontab" file.
3. If your script runs as is without any errors, all you have to do is add this line in crontab to run every monday at 9am
Code:
0 9 * * 1    /home/usr/script.sh

This User Gave Thanks to balajesuri For This Post:
# 3  
Old 02-24-2012
No errors are there in tha script..i want to change that script into corn and i want to run that corn script every monday morning automatically

Thanks in advance
# 4  
Old 02-24-2012
Ok, good. Now read point #2 and #3 of post #2 above.
# 5  
Old 02-24-2012
Additionally. Cron is a job scheduler in Unix environment helping to run scripts/jobs periodically. There is no need to change the code to run in cron but once you develop your code just add script-name plus time period to the crontab file. Though check here for further explanation. Often used options are
Code:
crontab -l # to lists cron entries
crontab -e # to edit/add cron entries. Use this option with caution

# 6  
Old 02-24-2012
so no nedd to open a the default editor (sudo crontab -e) and pasting the above script in that vi?????


so every monday running this command (0 9 * * 1 /home/usr/script.sh) is enuf? rite?

---------- Post updated at 06:31 AM ---------- Previous update was at 06:29 AM ----------

Thanks alot Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Shell script not working in crontab

Hi Iam running below script in crontab but its not working. #!/bin/sh cd /Scripts /usr/local/bin/expect -f /Scripts/bng_backup.exp /Scripts/data.txt tar -cf bngbackup.tar bngbackup ;gzip bngbackup.tar when iam running manually the output file is generating..but bngbackup.tar.gz file... (5 Replies)
Discussion started by: surender reddy
5 Replies

2. Shell Programming and Scripting

crontab using shell script to sync files.

Hi, I developed one shell script where it will sync the files using perforce, #!/bin/bash TERM=linux export TERM clear echo "" $PATH echo "" cd /u/userk/p4/p4_client/TES_DATE echo "" echo "Sync p4 " p4 sync echo "Executing for second time " p4 -u userk -p p4net:161 -c... (8 Replies)
Discussion started by: asak
8 Replies

3. Shell Programming and Scripting

use crontab for a shell script..

hi, i have shell script which checks for service running on platform, if service is receiving calls, then do nothing if service is not receiving calls, then stop the service i want to run this script in 2 timeslots. i.e. in the day from 9 am to 5 pm it should run every 10 minutes and ... (2 Replies)
Discussion started by: gauravah
2 Replies

4. Shell Programming and Scripting

Change crontab from shell script

Hi All, I have scheduled a script to run every five minutes through crontab. If there is any issue with the script which may need manual intervention, I have used the mailx commands. But at the same time, I would want the cron to be disabled until the issue is resolved. Once things are fine,... (2 Replies)
Discussion started by: adi_2_chaos
2 Replies

5. Shell Programming and Scripting

Adding a job to crontab via shell script

Is it possible to add a job to crontab with a shell script? The existing jobs in the crontab should exist as it was. The new job should be appended. Also, the crontab file is /var/spool/cron/root. (1 Reply)
Discussion started by: proactiveaditya
1 Replies

6. Shell Programming and Scripting

Can we edit crontab using a shell script

Hi, Can some one tell me if we can configure the jobs in crontab using a shell script. I know it can be done easily by using "crontab -e", but i just want to know whether we can add a job into the crontab using a shell script. If it can be done, plz suggest the procedure to do it. If it... (6 Replies)
Discussion started by: rudrarajumk
6 Replies

7. Shell Programming and Scripting

How do i run a shell script without crontab.

Hi Folks, Could you please suggest me how to run a shell script on a solaris env without using crontab. I am actually trying to write a shell script which will grep "WORD" in the logfile andd sends a email.Thanks in advance. Thanks Sandeep. (3 Replies)
Discussion started by: sandeep anand
3 Replies

8. UNIX for Dummies Questions & Answers

how to execute sh script in bash shell via crontab

hello. we are porting over from HPUX Shell to Linux. my default shell is bash so i can no longer schedule to execute a sh script in crontab. can anyone pls help me out? I searched the site but didnt find any details. thanks! (1 Reply)
Discussion started by: jigarlakhani
1 Replies

9. Shell Programming and Scripting

How to remove line from crontab in shell script?

Hi folks, I need to write a rollback script which removes the following line from the crontab: 0 0 * * * su - orca -c "/home/orca/core-<SCHEMA_NAME>/cleanup/CLI/cleanup_BRMS.ksh -c OC4J_RiGHTv_<SCHEMA_NAME>" <SCHEMA_NAME> is parameter. How to do it in ksh? Maybe it's better to backup the... (2 Replies)
Discussion started by: nir_s
2 Replies

10. Shell Programming and Scripting

crontab and shell script that executes a sql.

Problem: I have a crontab and when it kicks off, xxx.sh shell script is called. Which has a nohup sqlplus session call. Problem is sql does not get executed and a text file is not getting created. Only a empty log file is getting created. Are there any constraints for crontab to open a sql... (6 Replies)
Discussion started by: radhika
6 Replies
Login or Register to Ask a Question