SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: ssh crontab

  1. #1
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    ssh crontab

    Hello,,

    i created a file contain a cron job at /rename.cron
    then i executed the following in the shell > crontab /rename.cron

    now this has overwritten the existing crontab contents.
    how do i append a cron to crontab without replacing exisiting contents?


  2. #2
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,547
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    You need to open the existing cron file, read the contents and then append
    crontab -l list the existing cron entries, so something along the lines of (untested, so save your existing entries first!)

    crontab -l > somefilename; echo 'newcroncommandlinehere' >> somefilename; crontab somefilename

  3. #3
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by EastCoast View Post
    You need to open the existing cron file, read the contents and then append
    crontab -l list the existing cron entries, so something along the lines of (untested, so save your existing entries first!)

    crontab -l > somefilename; echo 'newcroncommandlinehere' >> somefilename; crontab somefilename
    Thanks East for the lesson.
    i did something like this already.
    shell>pico /var/spool/cron/root

    and just appended the cron job to the bottom of the file.
    is this method also accptable?

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    That is one way, another is running crontab -e
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    That is one way, another is running crontab -e
    Thanks cpradio for the confirmation!

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Just an FYI, there are reasons why you should use crontab -e instead of manually editing the file directly. There may be other reasons too, so be weary, what you did worked, but it isn't the ideal way of handling the situation.

    Edit:

    I still had an uneasy feeling about the process you took, so did a bit more searching to see if there was a reason NOT to do it that way. Didn't expect to find anything, but the above URL seems to be useful.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  7. #7
    SitePoint Guru afridy's Avatar
    Join Date
    Mar 2007
    Posts
    966
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cpradio View Post
    Just an FYI, there are reasons why you should use crontab -e instead of manually editing the file directly. There may be other reasons too, so be weary, what you did worked, but it isn't the ideal way of handling the situation.

    Edit:

    I still had an uneasy feeling about the process you took, so did a bit more searching to see if there was a reason NOT to do it that way. Didn't expect to find anything, but the above URL seems to be useful.
    Thank you so much. found some good information there!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •