Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

crontab issue

UNIX for Advanced & Expert Users


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-22-2009   -   Original Discussion by crackthehit007
crackthehit007's Unix or Linux Image
crackthehit007 crackthehit007 is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 2 June 2010, 4:06 AM EDT
Location: Pune/Banagalore
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
crontab issue

I am adding a piece of code which adds entry in crontab ((in brown color))


\crontab -l > $tmpfile
echo "Removing the cleanProcess entry if it already existed.."
grep -v "cleanProcess.sh" $tmpfile > $newtmpfile
lcnt=`grep -c "cleanProcess.sh" $tmpfile`
echo "Number of entries in cron is : $lcnt"
if [ $lcnt -eq 0 ]; then
echo "Entry didn't exist before. Adding new...."
echo "\n" >> $newtmpfile
else
echo "Entry already existed. Replacing it..."
fi
echo "0,5,10,15,20,25,30,35,40,45,50,55 * * * * $/test/bin/cleanProcess.sh" >> $newtmpfile
crontab $newtmpfile
echo "Added the new entry.."



crontab is empty ==>

$> crontab -l
$>


but file is having string as follows :

\n
echo "0,5,10,15,20,25,30,35,40,45,50,55 * * * * $/test/bin/cleanProcess.sh"


becoz of that the crontab is not able to initialized properly .

any anybody help me out whats wrong with it?

Last edited by crackthehit007; 03-22-2009 at 11:21 AM..
Sponsored Links
    #2  
Old Unix and Linux 03-22-2009   -   Original Discussion by crackthehit007
TonyFullerMalv's Unix or Linux Image
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 1 July 2013, 6:45 PM EDT
Location: Malvern, Worcs. U.K.
Posts: 1,033
Thanks: 0
Thanked 8 Times in 8 Posts
Solaris cron does not like empty lines and will not work that way as you have discovered, so your line:

Code:
echo "\n" >> $newtmpfile

needs to be:

Code:
echo "#\n" >> $newtmpfile

instead.
Sponsored Links
    #3  
Old Unix and Linux 03-22-2009   -   Original Discussion by crackthehit007
crackthehit007's Unix or Linux Image
crackthehit007 crackthehit007 is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 2 June 2010, 4:06 AM EDT
Location: Pune/Banagalore
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
my system is linux redhat.
and now entry in crontab is

$> crontab -l
#\n
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /test/bin/cleanProcess.sh




is that #\n is valid entry in crontab?

Last edited by crackthehit007; 03-22-2009 at 11:30 AM..
    #4  
Old Unix and Linux 03-22-2009   -   Original Discussion by crackthehit007
TonyFullerMalv's Unix or Linux Image
TonyFullerMalv TonyFullerMalv is offline Forum Advisor  
Registered User
 
Join Date: Sep 2008
Last Activity: 1 July 2013, 6:45 PM EDT
Location: Malvern, Worcs. U.K.
Posts: 1,033
Thanks: 0
Thanked 8 Times in 8 Posts
More valid than an empty line or a "\n", the crontab will now work, I see the \n is being treated literally, should have said:

Code:
echo "#" >> $newtmpfile

The \n is quite unnecessary! Should have realised that before, doh!
Sponsored Links
    #5  
Old Unix and Linux 03-23-2009   -   Original Discussion by crackthehit007
crackthehit007's Unix or Linux Image
crackthehit007 crackthehit007 is offline
Registered User
 
Join Date: Feb 2009
Last Activity: 2 June 2010, 4:06 AM EDT
Location: Pune/Banagalore
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot..
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Crontab email issue ryannam Solaris 5 06-20-2008 01:39 PM
Weird Issue with crontab. Cameron HP-UX 3 04-22-2008 12:36 AM
crontab issue vaddi HP-UX 11 01-28-2008 06:07 AM
Crontab Issue rickyt00 UNIX for Dummies Questions & Answers 2 08-06-2005 10:31 AM
crontab issue Semper_Tempus Solaris 6 07-19-2005 11:13 PM



All times are GMT -4. The time now is 02:53 PM.