Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I'm working with a Debian based Linux. Have a script that needs to be executed on boot. Found these instructions describing on how it needs to be one. My only difference is that I need to run a script with a parameter at bootup (myscript.sh --some-option 23). I can't use a wrapper script. I won't explain why, but I will only say that I just can't. Does anyone know how to do it?
The cron daemon has a #reboot command. That runs your script at reboot. So simply edit your crontab and add a line like this:
#reboot /your/script/test.sh
Assuming you are using a system with systemd, this is easy enough. Create a new service file "foo.service":
[Unit]
Description=Powertop autotune
[Service]
ExecStart=/usr/sbin/powertop --auto-tune # XXX replace with your command
[Install]
WantedBy=multi-user.target
and then install it:
ln -s /home/kris/Scripts/systemd/powertop.service /lib/systemd/system
systemctl enable powertop
systemctl start powertop
Obviously your paths and particulars will be different. In particular, the /lib/systemd/system might not be the right place in your distribution.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 10 months ago.
Improve this question
Recently I started working on Ubuntu 18.04.4 LTS machine. I have created a small project which should run from a docker container with command:
docker run docker_name "2022-04-11"
This command runs like a charm when I run it manually (I have sudo permissions), but breaks when I try to run it from sudo crontab.
I tried to log all output from the crontab to file myjob.log with command:
0 1 * * * docker run docker_name "2022-04-11" >> /home/projects/project/myjob.log 2>&1
Then I saw that myjob.log file contains an error message:
/bin/sh: 1: docker: not found
It got me confused. Why I can run docker commands, but crontab can't?
Check you crontab you are probably missing something like:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
If you are running as your user not root you have to add it to the top.
The short of it is that your $PATH isn't set so you can't find the docker command.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I connected via ssh to my Ubuntu server.
And I want to create a screen session with a command to run sh script.
I'm trying to do it this way:
screen -dm -S myserver server/start.sh
But nothing happens.
Even screen list is empty.
screen -list
No Sockets found in /run/screen/S-root.
How can I fix it?
Ubuntu 20.04, Screen version 4.08.00 (GNU) 05-Feb-20
Also, I want to put this command on system unit, to make systemd to run the script at system boot. But I can't to make it runs even using a command via ssh.
The problem was that script was failing with an error. I should make cd to run the script.
screen -S myserver -dm bash -c "cd server;sh start.sh"
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I've installed CoTURN on Ubuntu 16.04 server. I'm starting the TURN server with the below command:
turnserver -a -o -v -n --cert /etc/letsencrypt/live/mydomain.com/fullchain.pem --pkey /etc/letsencrypt/live/mydomain.com/privkey.pem -u username:password -r "mydomain.com"
I check with Trickle ice and it works fine. But after some random time (typically in days) it stops working/shuts down.
Is there any way to run it forever or at least get an email if the service stops?
Thanks!
I use the NPM tool called PM2 for that. If the service goes down, you can get notifications. Monit can do that - and also restart if necessary.
npm i pm2
pm2 start turnserver
sudo apt install monit
nano /etc/monit/monitrc
Here you can find examples how to enable a specific service. In your case it's the turnserver.
Config
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I've got a shell script which is supposed to install some packages from the Arch User Repository. The shell script is as follows:
#!/bin/sh
pacaur -S google-chrome --noconfirm # install google-chrome
The problem is, if I run this script using sudo sh script.sh, it'll just return: "you cannot perform this operation as root". If I run it without sudo, it'll ask for sudo later on when installing.
My question is, how can I avoid it asking me. I'd like this script to take care of installing all my packages just as is, without requiring me to actually give access manually. Would there be a way?
If you run sudo -v before calling the pacaur, this will ask you for your credentials and cache them for the next 15 minutes. You don't need to call sudo with pacaur anymore. As long as pacaur finishes running within the next 15 minutes, it will not have to ask for credentials again.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am trying to run a command that needs to write to the / folder. I added myself as user to sudoers file using sudo visudo. Added the following line at the end of file.
yedg ALL=(ALL) NOPASSWD: ALL
The command still fails complaining about permissions. Now this makes me wonder does adding to sudoers file allow me to run as root or does it give me privileges similar to root? Looks like the former. Am I right or did I miss something?
After you are added to sudoers file, you have permission to execute commands as root through sudo command.
Something like this:
sudo apt-get install skype
sudo rm -rf protectedDirectory
Actually sudo means substitute user do.