empty crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting empty crontab
# 1  
Old 04-13-2009
empty crontab

how to create empty crontab using shell script?
# 2  
Old 04-13-2009
Code:
crontab -e << EOF
dG:wq!
EOF

# 3  
Old 04-13-2009
actually this deletes all lines in your current crontab.
is this what you want ?!?!?
# 4  
Old 04-13-2009
no..
i just want to create new crontab if it is not there...
else update existing one
# 5  
Old 04-13-2009
it's automatically done through crontab -e.

Code:
export EDITOR=vi

crontab -e << EOF
aaddwhatever you want here^[:wq
EOF

where ^[ is the ESCAPE key entered in vi through CONTROL-V,ESCAPE sequence.
# 6  
Old 04-13-2009
\crontab -l
if [ $? -ne 0 ]; then
\crontab -e << EOF
else
\crontab -l > $tmpfile
fi

will it work?
# 7  
Old 04-13-2009
#!/bin/sh
export EDITOR=vi
osname=`uname`
if [ $osname = "Linux" ]; then
\crontab -l
if [ $? -ne 0 ]; then
\crontab -e << EOF
^[:wq
EOF
fi
else
\crontab -l
fi

giving error " line 14: syntax error: unexpected end of file"
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Empty Directories

Please help me. How i can find empty directories in solaris?? (4 Replies)
Discussion started by: FoDeGe
4 Replies

2. Shell Programming and Scripting

if/else with an empty file...

Hi there, I'm just starting out with shell scripting and I'm trying to make a test where the script will basically run yum check-update to find out if the server has any available and if it does it e-mails me but if not it will just stop there. I have it working if there are actually... (7 Replies)
Discussion started by: Imnewtothis
7 Replies

3. Shell Programming and Scripting

Need help If empty - perl

Hi, I need help if I list all the file that determined by user input and if program cannot find file it will display " there no file that you looking for " here is my code but it not working #!/usr/bin/perl -w print "Enter Advance Search Function: "; chomp ($func = <STDIN>); my @func1 =... (2 Replies)
Discussion started by: guidely
2 Replies

4. Shell Programming and Scripting

Empty out the file

Hi All, I have a piece of perl code in which I DON'T want to delete a file rather empty out the contents, here is the code - if ( unlink("$opt_b") == 1 ) { print_log( "$opt_b deleted", 1 ); }else { print_log( "Could not delete $opt_b:$!", 1 ); ... (5 Replies)
Discussion started by: jacki
5 Replies

5. Shell Programming and Scripting

while file is empty

how can i use while loop ? while file is empty do.... if not empty do ..... in bash (1 Reply)
Discussion started by: Trump
1 Replies

6. Shell Programming and Scripting

Need to empty

Hi, How can I empty the files of *.txt.... in one command. (6 Replies)
Discussion started by: gsiva
6 Replies

7. UNIX for Dummies Questions & Answers

Getting same exit status for empty and non empty file

Hi All, I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both. The value of $? is coming 0 in if part also and else part too. #!/bin/ksh if ]; then echo "data" # exit 0 echo "$?" else... (4 Replies)
Discussion started by: mavesum
4 Replies

8. UNIX for Dummies Questions & Answers

Crontab keeps saving empty files of the job file.

Hey, MAILTO=cron@domain.ca */20 * * * * /usr/bin/wget http://list.domain.ca/admin/consume.php >/dev/nullthats what the crontab is setup todo, so basically every 20minutes it runs consume.php In my root directory, i'm getting files like this: consume.php consume.php1 consume.php2 i woke... (3 Replies)
Discussion started by: iarp
3 Replies

9. UNIX for Dummies Questions & Answers

how to find empty folders without using -empty

hi all: my solaris FIND does not support find myFolder -type d -empty how can i find the empty folders? thanks! (7 Replies)
Discussion started by: lasse
7 Replies

10. Shell Programming and Scripting

empty dit

can anyone tell me how i can see if a directory contains no files thus is empty i use bash (4 Replies)
Discussion started by: jetfreggel
4 Replies
Login or Register to Ask a Question