F5F Stay Refreshed Software Operating Systems Scripts for Shell and Startup Management

Scripts for Shell and Startup Management

Scripts for Shell and Startup Management

M
manglemadness
Member
117
07-28-2024, 06:04 PM
#1
When a shell script runs via crontab, it typically stops after the next reboot unless configured otherwise. You can keep it active by adjusting the crontab settings or using a persistent process manager. This avoids the need to restart manually, similar to keeping a Java app running in a GUI.
M
manglemadness
07-28-2024, 06:04 PM #1

When a shell script runs via crontab, it typically stops after the next reboot unless configured otherwise. You can keep it active by adjusting the crontab settings or using a persistent process manager. This avoids the need to restart manually, similar to keeping a Java app running in a GUI.

M
Mr_Nestroke
Junior Member
46
08-01-2024, 12:14 PM
#2
I've never tried, but can't you just add it to the start up list? If for some messed up reason you can't just make a simple java script that starts it on start?
M
Mr_Nestroke
08-01-2024, 12:14 PM #2

I've never tried, but can't you just add it to the start up list? If for some messed up reason you can't just make a simple java script that starts it on start?

D
diyu_
Member
123
08-20-2024, 10:11 AM
#3
I'm not sure for cron, but as @Nater said theres more systematic ways to execute scripts at start up. But, assuming the cron job works the same as just adding the script to the "start up list" then it will only run once per boot. It will run once and end(unless you have a loop or restart or whatever) and will then run again upon restart.
D
diyu_
08-20-2024, 10:11 AM #3

I'm not sure for cron, but as @Nater said theres more systematic ways to execute scripts at start up. But, assuming the cron job works the same as just adding the script to the "start up list" then it will only run once per boot. It will run once and end(unless you have a loop or restart or whatever) and will then run again upon restart.

G
GGlobato
Member
176
08-20-2024, 06:21 PM
#4
They might both be scheduled via cron, depending on how they're configured.
G
GGlobato
08-20-2024, 06:21 PM #4

They might both be scheduled via cron, depending on how they're configured.

J
jarrah555
Member
50
08-21-2024, 05:50 PM
#5
Ubuntu 16.04 LTS and CentOS 7 both support systemd. In this case, the service file is located at "/lib/systemd/system/myscript.service". The unit configuration includes a description, targets, user permissions, execution command, and installation settings. To activate the service at startup, use systemctl enable myscript.service. After enabling, start it with systemctl start myscript.service and verify its status with systemctl status myscript.service. For more details, refer to the Arch Linux Wiki, which provides similar information for Ubuntu and CentOS.
J
jarrah555
08-21-2024, 05:50 PM #5

Ubuntu 16.04 LTS and CentOS 7 both support systemd. In this case, the service file is located at "/lib/systemd/system/myscript.service". The unit configuration includes a description, targets, user permissions, execution command, and installation settings. To activate the service at startup, use systemctl enable myscript.service. After enabling, start it with systemctl start myscript.service and verify its status with systemctl status myscript.service. For more details, refer to the Arch Linux Wiki, which provides similar information for Ubuntu and CentOS.

M
mateuszmamona
Member
174
08-21-2024, 10:08 PM
#6
Great! I'll give it a shot later.
M
mateuszmamona
08-21-2024, 10:08 PM #6

Great! I'll give it a shot later.

D
DangoBravo
Posting Freak
821
08-23-2024, 10:08 AM
#7
For running scripts at startup, cron is a good option. Your application will remain active until the system restarts or you reboot it. A better approach is creating an init.d script to start your app at boot and halt it before shutdown. You can find more details here, which might be useful.
D
DangoBravo
08-23-2024, 10:08 AM #7

For running scripts at startup, cron is a good option. Your application will remain active until the system restarts or you reboot it. A better approach is creating an init.d script to start your app at boot and halt it before shutdown. You can find more details here, which might be useful.

S
Suthurnbel
Member
182
08-23-2024, 10:40 AM
#8
It's possible this way, but a systemd service would be more effective. A better approach too.
S
Suthurnbel
08-23-2024, 10:40 AM #8

It's possible this way, but a systemd service would be more effective. A better approach too.