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 ?
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
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!