You are not logged in.
Hi Archers,
I've got a weird problem with a bash script I use to run pacman and mythtv updates once a week via cron which also reboots itself so that new mythtv and kernels packages become active. This script works likes a charm when I run it manually as user from the command line. But when cron runs it (also as user) it executes everything EXCEPT the last "sudo reboot" command at the end. Sudoers seems to be setup right as it works fine from the command line. I could run this particular script with cron as root but I'd prefer not to update under root with the --asroot command.
Any ideas? It seems like the permissions running manually and with cron are different somehow.
Many thanks!
Last edited by wdirksen (2012-10-09 13:07:28)
Research | Trial | Make Mistakes | Ask questions | Learn | Repeat
Offline
Post your /etc/sudoers file.
I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).
Offline
Thanks DSpider and falconindy for your replies
I will post the script and sudoers when I get home
Why would you use sudo in a cron job? Why not just add "reboot" to root's crontab?
The intention is for the machine to care of itself by performing a series of updates in the night once a week and rebooting itself. The "sudo pacman -Uf . . . " commands work fine and seems to make the most sense to me to give the reboot command at the end of the script when the updates are completed. Are you suggesting to schedule a separate reboot root cron job to run a few hours after the other user script runs?
Research | Trial | Make Mistakes | Ask questions | Learn | Repeat
Offline
The intention is for the machine to care of itself by performing a series of updates in the night once a week and rebooting itself. The "sudo pacman -Uf . . . " commands work fine and seems to make the most sense to me to give the reboot command at the end of the script when the updates are completed.
That sounds like fun. Skipping key checks, forcing everything, and then rebooting to top it off.
You're going to have a nasty surprise waiting for you one morning if you keep doing that. Arch is not a hands-free distro, don't automate your updates.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
That sounds like fun. Skipping key checks, forcing everything, and then rebooting to top it off.
You're going to have a nasty surprise waiting for you one morning if you keep doing that. Arch is not a hands-free distro, don't automate your updates.
Humm, food for thought. I did consider this but felt that up until now there has been nothing disasterous that couldn't be sorted manually later. But you are right, weird stuff does happen when initscripts, /usr/lib, are changed etc. I misquoted myself earlier. I don't -Uf mythtv. I have to do that occaisionally for something else.
Last edited by wdirksen (2012-10-09 15:26:42)
Research | Trial | Make Mistakes | Ask questions | Learn | Repeat
Offline
I have to agree with WorMzy. This sounds like a really bad idea. Even putting reboot in a cron job sounds strange to me, but automating updates with a reboot at the end just sounds crazy. If you update every day it doesn't take long to watch it happen.
Last edited by 2ManyDogs (2012-10-09 15:36:01)
Offline
A while back, I found something... can't find it at the moment... that would check the news, and then update while ignoring anything that was mentioned. This might be safer, but I still would prefer to do it manually.
Offline
OK, I'm going to reconsider this based on all your advices, but I'm still curious about why the command doesn't execute with cron. Related to this, I also find it strange that some root commands work fine with sudo, while others only work within a true root environment
Post your /etc/sudoers file.
So here's my sudoers file:
## User privilege specification
##
root ALL=(ALL) NOPASSWD: ALL
mythtv ALL=(ALL) NOPASSWD: ALL
. . . and this is the script:
#!/bin/bash
#
sudo pacman -Syyu --noconfirm
#
/usr/share/mythtv/optimize_mythdb.pl
/usr/share/mythtv/mythconverg_backup.pl --rotate 20
#
mythtvname="mythtv-git-$(date +%Y%m%d)-1-x86_64.pkg.tar.xz"
#
cd /home/mythtv/AUR/mythtv-git
makepkg
sudo pacman -U $mythtvname --noconfirm
#
sudo reboot
Anything stick out here?
Last edited by wdirksen (2012-10-09 19:32:52)
Research | Trial | Make Mistakes | Ask questions | Learn | Repeat
Offline
Try "sudo shutdown -r now" instead of "sudo reboot"
Last edited by 2ManyDogs (2012-10-09 18:35:03)
Offline
(0. Switch to systemd)
1. Create a polkit rule for "systemctl reboot" or just "reboot"
2. Let the script reboot
3. Be happy.
Offline
You void your warranty for forum help if you choose to do unattended upgrades.
You're going to have a nasty surprise waiting for you one morning if you keep doing that. Arch is not a hands-free distro, don't automate your updates.
You should rather update less often if you do not have the time for attending the upgrade.
You use mythtv , is your real problem not having physical access to the machine using the keyboard?
I recommend you to use an ssh login for updating instead of automatic updating.
Offline
DSpider wrote:Post your /etc/sudoers file.
So here's my sudoers file:
## User privilege specification ## root ALL=(ALL) NOPASSWD: ALL mythtv ALL=(ALL) NOPASSWD: ALL
You shouldn't run everything as root.
Just posted this yesterday: https://bbs.archlinux.org/viewtopic.php … 0#p1173450
I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).
Offline