Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Run shell script one time only

  1. #1

    Default Run shell script one time only

    Hello Expert,

    I am trying to run sell script just one time when the Linux start. I am not sure whether I should use cron job as I dont want to run the script more than one time.

    let me know if you need more information.

    can you please help?

    Regards,
    Hardik

  2. #2
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,317

    Default Re: Run shell script one time only

    On Mon, 17 Mar 2014 17:36:01 +0000, hpatel18 wrote:

    > Hello Expert,
    >
    > I am trying to run sell script just one time when the Linux start. I am
    > not sure whether I should use cron job as I dont want to run the script
    > more than one time.


    One time ever, or one time per boot?

    If one time per boot, then @reboot is, as I recall, the keyword you
    need. See 'man 5 crontab'.

    Other options would be to create a service file to run it, or use an 'at'
    job.

    Jim
    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  3. #3

    Default Re: Run shell script one time only

    Hi Jim,

    Thanks for your prompt response.

    I just want to run "one time ever" and not the "one time per boot". sorry for the confusion.

    Regards,
    Hardik

  4. #4
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,317

    Default Re: Run shell script one time only

    On Mon, 17 Mar 2014 18:26:01 +0000, hpatel18 wrote:

    > I just want to run "one time ever" and not the "one time per boot".
    > sorry for the confusion.


    You could just run it from a terminal window, then - unless it's part of
    a deployment process you're using. What's the purpose of the script in
    question?

    You could get fancy and create a service file that deletes itself when
    the script has run, but if you just need to run it once when the system
    boots

    Jim
    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  5. #5

    Default Re: Run shell script one time only

    Hi Jim,

    I have created a VM for my developers and that script has some commands which change some configuration in the software license.

    Regards,
    Hardik

  6. #6
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,317

    Default Re: Run shell script one time only

    On Mon, 17 Mar 2014 19:06:02 +0000, hpatel18 wrote:

    > Hi Jim,
    >
    > I have created a VM for my developers and that script has some commands
    > which change some configuration in the software license.


    I see - pretty much what I guessed, then - part of a deployment process.

    Maybe take a look at the openSUSE "firstboot" script to see how that's
    done - I seem to remember that it cleans itself up so it only runs once
    as well, seems like a good fit for what you're trying to accomplish.

    Jim



    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  7. #7
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: Run shell script one time only

    On 2014-03-17 23:29, Jim Henderson wrote:
    > On Mon, 17 Mar 2014 19:06:02 +0000, hpatel18 wrote:
    >
    >> Hi Jim,
    >>
    >> I have created a VM for my developers and that script has some commands
    >> which change some configuration in the software license.

    >
    > I see - pretty much what I guessed, then - part of a deployment process.


    Er... this is the howto submission forum. No questions ;-)

    --
    Cheers / Saludos,

    Carlos E. R.
    (from 13.1 x86_64 "Bottle" at Telcontar)

  8. #8
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,659

    Default Re: Run shell script one time only

    Quote Originally Posted by hpatel18 View Post
    Hi Jim,

    I just want to run "one time ever" and not the "one time per boot". sorry for the confusion.
    You could try a self-deleting script. Read http://www.unix.com/shell-programmin...ng-script.html

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,798

    Default Re: Run shell script one time only

    Quote Originally Posted by robin_listas View Post
    Er... this is the howto submission forum. No questions ;-)
    Indeed. This is the forum to post unreviewed Howtos. It says in a rather big font:
    This forum is NOT for asking questions, but .......
    This will be moved to Programming/Scripting to be made known to the correct audience.

    This is CLOSED for the moment.
    Henk van Velden

  10. #10
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,798

    Default Re: Run shell script one time only

    Quote Originally Posted by hcvv View Post
    This is CLOSED for the moment.
    Moved from Unreviewed Howto and FAQ and open again.
    Henk van Velden

Page 1 of 2 12 LastLast

Posting Permissions

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