rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Fri Dec 18, 2015 10:57 pm

Hey!..... One of the last few minutes of the day.

This worked.

On sudo crontab -e
I added a line
time sudo /usr/bin/ap-get update && sudo /sbin/reboot

And it has rebooted. So the cronjob ran, must have updated, and then it restarted.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Fri Dec 18, 2015 11:01 pm

Set one to update, upgrade, reboot for tomorrow morning.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Mon Dec 21, 2015 2:52 pm

This works, but I'm still thinking on it.

On my Ubuntu machine,
sudu crontab -e
00 5 * * * sudo /usr/bin/apt-get update && sudo /usr/bin/apt-get upgrade -y && sudo /sbin/reboot

I'm taking off the reboot part. Maybe I'll run that a couple times a day.


Questions...
I thought if I was running sudo crontab -e that I didn't need to use sudo in the lines. It looks like it won't run without that.

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Cronjob / Linux command line question

Mon Dec 21, 2015 4:11 pm

Why not install "cron-apt - automatic update of packages using apt-get" and get all the hardwork done for you?

There are lots of reasons why automating apt-get update && apt-get upgrade are an exceedingly bad idea, but it's your weapon, your round and your foot. Just don't come complaining about large holes in your feet when your weapon goes off unexpectedly.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Mon Dec 21, 2015 4:38 pm

Hm. I didn't know there was one.

Would that be...
sudo apt-get cron-apt-automatic

?

Now part is to learn a little more about Linux -- command line, cronjobs, etc. That's probably the real payoff.

Otherwise, it was just to automate, to save time. If I'm thinking about it, I run it manually. If something goes bad, the only thing will be when I might notice it -- Probably sooner if I manually run the update. A little later if it's automatic. Unless the machine shuts off. I might notice that sooner.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Mon Dec 21, 2015 4:40 pm

Think I found it. Some info here.


https://help.ubuntu.com/community/AutoWeeklyUpdateHowTo

sudo apt-get install cron-apt


I wonder if I can tweak the time though. I set my Ubuntu machine to update/upgrade at 5am, 1pm, and 6pm daily, no restarts.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Mon Dec 21, 2015 9:38 pm

Something interesting here.

http://unix.stackexchange.com/questions ... in-crontab

Run it once and have it go off again every so many minutes or hours. I wonder how it knows when to stop.

DirkS
Posts: 10018
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Cronjob / Linux command line question

Tue Dec 22, 2015 6:17 am

rasprm3 wrote:Something interesting here.

http://unix.stackexchange.com/questions ... in-crontab

Run it once and have it go off again every so many minutes or hours. I wonder how it knows when to stop.
When the rules you enter on the crontab line aren't met.
The stackexchange example doesn't stop, it runs every 5 minutes.
If you would use '0-10/5' in the minutes field it would run every hour at the full hour, 5 past and 10 past

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Tue Dec 22, 2015 3:36 pm

Yeah I was thinking you kill the process probably. Not great, but possible.

I'd rather have it controlled with specific times I pick instead of an unending "every x-minutes" task.

rasprm3
Posts: 195
Joined: Sun Jan 20, 2013 1:27 am

Re: Cronjob / Linux command line question

Wed Dec 23, 2015 2:33 pm

This is on my Ubuntu machine.

Assuming I've got a working cronjob for updates and upgrades....

Why does the GUI Software Updater still pop up? I thought it would already do updates/upgrades in the background with the cronjob.

It is still downloading something.

I've got the update GUI window settings set to check for updates daily, download whatever's available.

It's installing now... "linux-image-3.15.0-57-generic"

If these are already installed it might just be checking. Why does this GUI update box even show up though?

And now it wants a restart, which is fine....


Checking update settings, under Software & Updates
Checked -- Important security updates (trusty-security)
Check Recommended updates (trusty-updates)
no pre-release
Check Unsupported updates (trusty-backports)

I switched it to daily today.
Display immediately for when for security and other updates.

Notify me of new Ubuntu versions -- for long-term support versions. Except this is the highest Ubuntu version for this machine. If it gets upgraded, it breaks.


Maybe an update came out between early this morning and now.

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Cronjob / Linux command line question

Thu Dec 24, 2015 12:23 am

rasprm3 wrote:Yeah I was thinking you kill the process probably. Not great, but possible.

I'd rather have it controlled with specific times I pick instead of an unending "every x-minutes" task.
I expect there may be some good scheduling software available for free. I've not looked, but in past lives I've used CA-Scheduler, Command VSE, Autosys and Maestro (shudder).

Return to “Beginners”