Linux - Run Script after reboot
-
@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.
-
@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.
-
Reboot again and then post the output of
journalctl -u cron -n 25
. -
@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)?
-
@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?
-
@travisdh1 Good eye. In the OP, he indicated /tmp, not /home.
-
@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.
-
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.
-
@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?
-
@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?
-
I might implement a script like this. Care to share the script itself?
-
@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
-
This post is deleted! -
@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.