Timeline for How to run a PowerShell file during boot as root on Asterisk?
Current License: CC BY-SA 4.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 30, 2021 at 7:03 | vote | accept | admiri | ||
| Apr 29, 2021 at 14:18 | answer | added | C. M. | timeline score: 1 | |
| Apr 29, 2021 at 6:59 | comment | added | admiri | @C.M. Like you said I hadn't specified for which user to edit crontab. Now I used contab - u root -e and it worked. You can post your answer to this post and I can mark it as Answered/Solved. Thank you. | |
| Apr 28, 2021 at 7:17 | comment | added | Chris Davies | Please add type pwsh to your question; it shows us where the executable can be found | |
| Apr 28, 2021 at 6:57 | history | edited | admiri | CC BY-SA 4.0 | added 95 characters in body |
| Apr 27, 2021 at 12:39 | comment | added | C. M. | Okay, now show us the line you tried with crontab? And which crontab did you edit? There is a system crontab as `/etc/crontab' and each user has their own per-user crontab (including root, so editing as root only modifies root's crontab, not the system one). The system one adds a field to specify which user to run as. Also, there are some special constructs (such as as @reboot). But you will not need that, since "once every minute" includes boot time. | |
| Apr 27, 2021 at 12:29 | comment | added | admiri | @C.M. i just made an edit to this question | |
| Apr 27, 2021 at 11:59 | history | edited | admiri | CC BY-SA 4.0 | improved formatting |
| Apr 27, 2021 at 9:06 | comment | added | C. M. | If once per minute is good enough, consider using a cron job (look up the cron command as well as information on cronab, the configuration file for cron.) In the future, before asking a question, try to research the problem from different directions than only the one you are trying to do; There may already different solutions that work. In a un*x system, running a .ps1 file in an infinite loop via an rc.* file will likely load down your CPU needlessly. | |
| Apr 27, 2021 at 8:59 | comment | added | C. M. | So back to your original problem... As you describe what the .ps1 file does, you need to keep one (or more) directories/files synchronized between Asterisk and your Azure storage, correct? Have you looked in to the command rsync for this? It has many options to do exactly that in many different ways. And the las part, you wan to make sure i is run continuously. How do you define continuously? Each microsecond? Each millisecond? Each second? Or is once a minute good enough? | |
| Apr 27, 2021 at 8:55 | comment | added | C. M. | Regarding that last command, the first part, sudo basically means "run as root" (I.E., the System account, if you're used to Windows accounts, which is even more powerful than the Administrator account). the second part is the command to run, chmod, which changes file level permissions of the filenames listed. So the final parts, systemctl enable and rc-local are not being treated as commands--they're being treated as three filenames for chmod to operate on. Which does not match what you say you think it does. | |
| Apr 27, 2021 at 8:54 | comment | added | C. M. | I will need to use more then one comment for all this.. So read them all first. First, Edit your question to reflect any changes needed. (Usually, when a comment asks you for more information, you should edit the question to include the information, such as copy/pasting he relevant parts of the .ps1 file.) But that may not be needed after all.. read the next comments(s).. | |
| Apr 27, 2021 at 7:01 | comment | added | admiri | @C.M. .ps1 is supposed to copy new files from an asterisk directory and transfer them to an Azure storage container. I'm using Sangoma Linux (CentOS 3.10.0). That command is supposed to look if there’re is any problem with root, so the command on /etc/rc.local can be executed on the root as default; and to not be executed on the default user. | |
| Apr 26, 2021 at 14:19 | comment | added | C. M. | Please provide further information. What is the .ps1 supposed to do? What is your OS and version? I am also confused about that whole line sudo chmod systemctl enable rc-local ... What do you think that command is supposed to do? | |
| Apr 26, 2021 at 11:52 | review | First posts | |||
| Apr 26, 2021 at 14:19 | |||||
| Apr 26, 2021 at 11:45 | history | asked | admiri | CC BY-SA 4.0 |