ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Linux - Run Script after reboot

    Scheduled Pinned Locked Moved IT Discussion
    21 Posts 7 Posters 3.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • thwrT
      thwr @hobbit666
      last edited by

      @hobbit666 said in Linux - Run Script after reboot:

      Doesn't seem to be working.

      systemctl status crond.service

      shows cron is running.

      crontab -e

      added the line

      @reboot /home/set-up.sh

      but when I reboot and log back in as root nothing 😞 guess i'm missing something

      Not every cron implementation supports @reboot states.

      scottalanmillerS 1 Reply Last reply Reply Quote 0
      • DustinB3403D
        DustinB3403
        last edited by

        What distro are you using?

        thwrT 1 Reply Last reply Reply Quote 0
        • thwrT
          thwr @DustinB3403
          last edited by

          @DustinB3403 said in Linux - Run Script after reboot:

          What distro are you using?

          The question should be: which cron? vixie, anacron, fcron or systemd maybe?

          DustinB3403D DanpD 2 Replies Last reply Reply Quote 1
          • DustinB3403D
            DustinB3403 @thwr
            last edited by

            @thwr said in Linux - Run Script after reboot:

            @DustinB3403 said in Linux - Run Script after reboot:

            What distro are you using?

            The question should be: which cron? vixie, anacron, fcron or systemd maybe?

            I suppose, the distro should have given us that info though.

            1 Reply Last reply Reply Quote 1
            • DanpD
              Danp @thwr
              last edited by

              @thwr said in Linux - Run Script after reboot:

              The question should be: which cron? vixie, anacron, fcron or systemd maybe?

              @hobbit666 said in Linux - Run Script after reboot:

              Doesn't seem to be working.

              systemctl status crond.service

              I would assume systemd based on the above.

              1 Reply Last reply Reply Quote 1
              • DanpD
                Danp
                last edited by

                Reboot again and then post the output of journalctl -u cron -n 25.

                1 Reply Last reply Reply Quote 0
                • DanpD
                  Danp @hobbit666
                  last edited by

                  @hobbit666 said in Linux - Run Script after reboot:

                  added the line

                  @reboot /home/set-up.sh

                  but when I reboot and log back in as root nothing 😞 guess i'm missing something

                  Have you verified that the script can be run manually (have you set 'execute' permission)?

                  1 Reply Last reply Reply Quote 0
                  • travisdh1T
                    travisdh1 @hobbit666
                    last edited by

                    @hobbit666 said in Linux - Run Script after reboot:

                    Doesn't seem to be working.

                    systemctl status crond.service

                    shows cron is running.

                    crontab -e

                    added the line

                    @reboot /home/set-up.sh

                    but when I reboot and log back in as root nothing 😞 guess i'm missing something

                    I doubt /home/set-up.sh is the correct path, if it is, you need to create more users! Or did you mean /root/set-up.sh?

                    DanpD 1 Reply Last reply Reply Quote 0
                    • DanpD
                      Danp @travisdh1
                      last edited by

                      @travisdh1 Good eye. In the OP, he indicated /tmp, not /home.

                      J 1 Reply Last reply Reply Quote 2
                      • scottalanmillerS
                        scottalanmiller @thwr
                        last edited by

                        @thwr said in Linux - Run Script after reboot:

                        @hobbit666 said in Linux - Run Script after reboot:

                        Doesn't seem to be working.

                        systemctl status crond.service

                        shows cron is running.

                        crontab -e

                        added the line

                        @reboot /home/set-up.sh

                        but when I reboot and log back in as root nothing 😞 guess i'm missing something

                        Not every cron implementation supports @reboot states.

                        But all on available Linux do.

                        1 Reply Last reply Reply Quote 0
                        • hobbit666H
                          hobbit666
                          last edited by

                          Yes script runs and does what I want. I should of mentioned it has some prompts for user input.
                          It's a script to basically set-up networking on CentOS7 for basic IT Staff on new VM's so they don't have to edit the files direct.

                          So I idea is once CentOS is installed add the script to start on next boot, shut the VM down then use it to clone new ones. As it will ask for hostname and static IP.

                          scottalanmillerS thwrT 2 Replies Last reply Reply Quote 0
                          • scottalanmillerS
                            scottalanmiller @hobbit666
                            last edited by

                            @hobbit666 said in Linux - Run Script after reboot:

                            So I idea is once CentOS is installed add the script to start on next boot, shut the VM down then use it to clone new ones. As it will ask for hostname and static IP.

                            Interesting idea. Does it force it, or just remind to do it?

                            1 Reply Last reply Reply Quote 0
                            • J
                              Jstear @Danp
                              last edited by

                              @Danp said in Linux - Run Script after reboot:

                              @travisdh1 Good eye. In the OP, he indicated /tmp, not /home.

                              I'm with these two. Are you 100% you have the correct path?

                              1 Reply Last reply Reply Quote 0
                              • scottalanmillerS
                                scottalanmiller
                                last edited by

                                I might implement a script like this. Care to share the script itself?

                                hobbit666H 1 Reply Last reply Reply Quote 0
                                • thwrT
                                  thwr @hobbit666
                                  last edited by

                                  @hobbit666 said in Linux - Run Script after reboot:

                                  So I idea is once CentOS is installed add the script to start on next boot, shut the VM down then use it to clone new ones. As it will ask for hostname and static IP.

                                  You could also use something like Ansible instead

                                  1 Reply Last reply Reply Quote 1
                                  • J
                                    Jstear
                                    last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • hobbit666H
                                      hobbit666 @scottalanmiller
                                      last edited by

                                      @scottalanmiller said in Linux - Run Script after reboot:

                                      I might implement a script like this. Care to share the script itself?

                                      Not back in till Wednesday but it's a simple one so far

                                      Asks for a hostname on a prompt and runs hostnamectl
                                      Then asks for ip to assign and runs a few sed commands to edit the cfg-eth0 file.

                                      So the main idea is to run the command/script when root logs in next.

                                      1 Reply Last reply Reply Quote 1
                                      • 1
                                      • 2
                                      • 2 / 2
                                      • First post
                                        Last post