Cronjob


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cronjob
# 1  
Old 02-25-2009
Cronjob

Hi,

I'm totally new to shell scripting. I need help in my crontab script. I'm trying to read some values from user (username, log file directory, server) and then use those value to create a crontab for log rotation after some interval of time.

creating crontabs manually isn't big deal. Infact I have made crontab file, in which i replace the info with the new one.

Can any of you help in this regards as to how to replace the input values in the code that I have and then running a crontab command such that it has all the necessary info ?

Please a little help. Smilie
# 2  
Old 02-25-2009
You can create a script dynamically using all the parameters you require.

schedule this script in the cron job.

step 1 cron script test.sh in crontab
step 2 create scripts which runs impoting whatever paratemeters or variables are required.

so test.sh may have something like

username=who am i|tr ' ' ''|cut -d ' ' -f1

Please illustrate if you have any specific requirement

Regards

w020637
# 3  
Old 02-25-2009
Cronjob

deleted

Last edited by MisterKhan; 02-26-2009 at 11:04 AM..
# 4  
Old 02-26-2009
Duplicate post... pls read the rules...

Last edited by otheus; 02-26-2009 at 06:09 AM.. Reason: Threads merged
# 5  
Old 02-26-2009
@ w020637

It would be more helpful if you explained with a little example.
Thanks.
# 6  
Old 02-26-2009
MisterKhan

Crontab is primarily used for scheduling jobs. If it a simple one liner you can embedd in the crontab but if its a set of tasks then it would be better to put it in a shell script. So what ever task need to be accomplished need to be done in another shell script test.sh which will be scheduled in the crontab. So

step 1 cron script test.sh in crontab
30 18 * * * /test.sh

step 2 create script which runs impoting whatever paratemeters or variables are required.

so test.sh may have something like

username=who am i|tr ' ' ''|cut -d ' ' -f1

Regards
# 7  
Old 03-03-2009
Okay ... I think I'm getting a hold of scripting now .... I've created some script which does what I want ... but not fully. Here is the summary.

[assumption: script is run as root.]
*I have created an input (or properties) file ... which asks the user to input some information such as user name, log directory path, server name etc.
*Then, it substitutes these input values from the user to another file, say, cron.txt.
* next step is to copy this file from the root to the user's directory (e.g. user1) and then change the permission of that file.
* last step is to do "crontab cron.txt".

I'm facing problem in the last step. Instead of doing this command in the user's home directory, it makes the changes in the root's crontab ...

I hope someone gives me a suggestion ... Please help!

Thanks.

MisterKhan
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cronjob

How to set cronjob for 48 hours. I can set for 2 days as shown below. * * */2 * * It is creating confusion for 30 days & 31 days per month. (3 Replies)
Discussion started by: Nishit
3 Replies

2. UNIX for Dummies Questions & Answers

cronjob

Is the cronjob below can run only first wednesday of every month? 30 5 1-7 * 3 command please tell me (3 Replies)
Discussion started by: Anjan1
3 Replies

3. Shell Programming and Scripting

Cronjob not exexcuting!

I have a script named email_kill.sh which kills the EMAIlL engine process. See the below content: #! /usr/bin/ksh -x PID=`ps -eaf | grep "AREmail" | tail -1 | awk '{print $2}'` echo "$PID" kill -9 "$PID" For this script to execute every hour I made a cronjob: 0... (2 Replies)
Discussion started by: nixhead
2 Replies

4. UNIX for Dummies Questions & Answers

Cronjob help

Hi I am very new to linux. I want to run a cronjob every 15 minutes that checks a directory for files. If the directory contains more than ten files I want it to send an email to me. All I have is this... */15 * * * * ls -l | wc -l | | mail -s "This is just a test" I would... (2 Replies)
Discussion started by: LinuxNewb
2 Replies

5. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

6. AIX

cronjob

Hi, I want to schedule a script on daily basis in morning 8:00 A.M and 5:00 P.M , how can i achieve this, i want the parameter 0 ? * * * what will be the second parameter in my case. Regards (1 Reply)
Discussion started by: maooah
1 Replies

7. Solaris

at vs cronjob

HI, What is the differnece between at / con job? thanks in advance. (1 Reply)
Discussion started by: mokkan
1 Replies

8. UNIX for Dummies Questions & Answers

cronjob

hi iam new at unix.iam running a cronjob,which i want to run on the first day of every month at 1AM.this is what i have specified: 00 01 1 * * is this corect? (1 Reply)
Discussion started by: wiz83
1 Replies

9. HP-UX

CronJob

Dear Guru, I have submitted some cronjobs that has been running for quite sometimes. However, today I counter some cronjob did not run. Can you please explain what causes this to happen. Any system setting that limit number of cronjob per minutes to be started, etc? Thanks. Kelly (1 Reply)
Discussion started by: hcng08
1 Replies

10. Shell Programming and Scripting

Cronjob

Please can someone help me. I need to set up a cron job to measure CPU usage, Disk I/O and memory usage over a period of 1 minute along with the number of users logged into the system. I also need to send it to another user besides myself every hour. Please can someone help me! Thanks. (4 Replies)
Discussion started by: gerwhelan
4 Replies
Login or Register to Ask a Question