Add item to crontab


 
Thread Tools Search this Thread
Operating Systems Solaris Add item to crontab
# 1  
Old 02-23-2010
Error Add item to crontab

hi,
how can I add a new value to crontab file using a script not using the command " crontab -e " .
ex:
Code:
echo " 10 10 * * * " >> /var/spoll/cron/crontabs/<username>

how can I do that in a correct way??

thanks,

Last edited by zaxxon; 02-23-2010 at 07:18 AM.. Reason: use code tags please
# 2  
Old 02-23-2010
The above is what I would do, which is the simplest method. I don't understand what you're looking for...
# 3  
Old 02-23-2010
editing crontab

You can also use the crontab -l a nd redirect to a temp file. Use vi to make your change and then resubmit the file to the cron

e.g.
Code:
crontab -l > /var/tmp/root.txt
vi /var/tmp/root.txt
crontab root.txt


Last edited by Scott; 02-23-2010 at 07:36 PM.. Reason: Please use code tags
# 4  
Old 02-23-2010
hydrashok128 approach is good. Personally I would copy the crontab twice under different names to preserve the original if the edit goes wrong. Always post the crontab with a "crontab" command because this validates the file.
Adding a line to crontab can be scripted by this approach.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Confused on how to script item

I am working on a script that will parse the /proc/meminfo file and return values. I have been able to pull the MemTotal and MemFree from that file but have stumbled on the next thing I want to do - calculate memory used via subtracting MemFree from MemTotal. Would I do something like - ... (5 Replies)
Discussion started by: flyboynm
5 Replies

2. Solaris

cannot add PATH to user crontab file

hi All, here is the problem: I'm not able to specify a PATH inside the user crontab file (/var/spool/cron/crontabs). The only syntax it accepts is the usual "* * * * * file" I'm not able to add PATH, or HOME, or MAILTO, or anything else. when I try to save the crontab, I have the error: ... (1 Reply)
Discussion started by: joe_x
1 Replies

3. Shell Programming and Scripting

How to add a script to Crontab?

Hi! We are on AIX 5.3 I have a script that must be run once every hour. How do i add this to the crontab? I know how to access crontab which is, crontab -e. What do i do after that ? If i have the path to the script? Thank you!!! (4 Replies)
Discussion started by: atechcorp
4 Replies

4. Shell Programming and Scripting

How to add cron job in /etc/crontab

Hi, How to add a cron job in /etc/crontab using a shell script.??:confused: Actually the requirement is we need to run a script say, XXX.sh every 10 min through “cron”. That can be achieved by adding the below code line in the /etc/crontab , (i.e., “crontab -e ” command to add this to the... (4 Replies)
Discussion started by: Dedeepthi
4 Replies

5. UNIX for Dummies Questions & Answers

replace item..

Hello, I have the following basic script which is remove the fielld. How can I replace another value in the field? Thx!! for file in `cat $listn.txt` do get_file -q $file grep -v '<customer-id>13000</customer-id>' $file > $file.grep done echo All processed file done!! input file:... (2 Replies)
Discussion started by: happyv
2 Replies

6. Shell Programming and Scripting

find an available item in array

Dear all, I'm have a sorted array like this: 177 220 1001 2000 2001 2003 2005 notice that 2002 and 2004 are NOT in array. Then user input a number INPUT, our script should return OUTPUT value like this: if INPUT is not in array => OUTPUT=INPUT if INPUT is in array => OUTPUT is the... (4 Replies)
Discussion started by: fongthai
4 Replies

7. Shell Programming and Scripting

change some record item

Hi all, I have a file with over 10,000 line, but I would like to update/add some code number (such as 062 below) into the line with <phone number> below: 11111<name> john matin <name> 12345<phone number> 123456 <phone number> 34556 <address> 1234 lucky road <address> 11111<name> john... (7 Replies)
Discussion started by: happyv
7 Replies

8. Shell Programming and Scripting

Removing an item from the dock

Hello! I am able to add an item to the dock with this command: defaults write com.apple.dock persistent-apps -array-add... (1 Reply)
Discussion started by: emperorfabulous
1 Replies
Login or Register to Ask a Question