PDA

View Full Version : [SOLVED] Question about Cron Jobs



throese
November 11th, 2010, 12:52 AM
So, last night, I did a little research and think using Cron Jobs are awesome. However, I have a slight problem.

I have a file that I made called "update_manager.sh" and have it set up to use the update manager, but you have to hit "y" for yes or "n" for no. I have it set so the update manager starts at 2:05 EVERY day of the week at that time specifically. But, my problem is, I don't wanna stay up that late just to press "y" every time. How do I make it so "y" is always chosen?

u-slayer
November 11th, 2010, 03:32 AM
echo y | updatemanager.sh

throese
November 11th, 2010, 04:01 AM
Thanks. I'm sure it will work

throese
November 12th, 2010, 04:38 AM
And it didn't work, the "echo y | update_manager.sh" part. What do I try now?

CharlesA
November 12th, 2010, 05:14 AM
So you want to apply updates every day at 2am?

Why not just use unattended updates? You can do normal updates with it by uncommenting that line in /etc/apt/apt.conf.d/50unattended-upgrades)

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

If that's not what you want, you can just use apt-get upgrade --assume-yes, but that may upgrade something you didn't want upgraded.

throese
November 12th, 2010, 05:46 AM
Charles: But I only have unlimited bandwidth from 2 AM to 7 AM and I can't stay up that late. That's why I want to set a Cron Job to do it. I'm sure I want everything updated, but I'll always check during the day before letting the cron job update.

CharlesA
November 12th, 2010, 01:57 PM
If that's the case, you can always just have it run this:


#!/bin/bash
apt-get update && apt-get upgrade --assume-yes

Throw it in a cronjob and that should get it working.

throese
November 13th, 2010, 12:27 AM
I don't understand the "--[insert word here]" part. Why do people do that?

Example: shutdown --help

or when you're backing stuff up.

Ex: --exclude=/mnt

So what would "--assume-yes" do?

CharlesA
November 13th, 2010, 12:43 AM
See here:


--assume-yes
Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively. If an undesirable situation, such as changing a held package or removing an essential package occurs then apt-get will abort. Configuration Item: APT::Get::Assume-Yes.

It's just a switch.

throese
November 13th, 2010, 01:55 AM
It didn't work Charles. =(

CharlesA
November 13th, 2010, 01:16 PM
Did you use the full path, I forgot to mention that.

Also add "> /home/username/somefile 2>&1" to the end of the entry in the crontab to see what it's doing.

throese
November 13th, 2010, 09:14 PM
Doesn't matter, I updated it last night. Stayed up till 5:00 AM