Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there an app to mute the computer say 10PM to 7:30AM? (On Android devices I use: phone silencer app )

share|improve this question
1  
We do that from command line. See this duplicate: askubuntu.com/questions/26068/… All you need to do is toss the command in /etc/crontab with a time stamp. –  Rinzwind Jan 2 '13 at 19:50
    
I don't think that's a close enough dupe. OP needs help scripting this. –  Tom Brossman Jan 2 '13 at 21:04

1 Answer 1

up vote 3 down vote accepted

Following the link in the comments of @Rinzwind: How do you mute from the command line?

Use crontab to mute and unmute the computer at night as follows:

Open a terminal by pressing Ctrl+Alt+T and enter one of the the following lines to edit the /etc/cron.d file:

For a regular user, use the following command:

crontab -e

For system-wide solution, use the following command:

sudo crontab -e

At the end of the resulting file add the following two lines:

00 22 * * * amixer set Master mute
29 07 * * * amixer set Master unmute

Press Ctrl+X and then Y to save and exit crontab.

Explanations:

Each of the crontab sections is separated by a space, with the final section having one or more spaces in it. No spaces are allowed within Sections 1-5, only between them. Sections 1-5 are used to indicate when and how often you want the task to be executed. This is how a cron job is laid out:

minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), command

See the CronHowto in Ubuntu Help for more details.

Note: This will not work if the machine is off at the predefined time. For example, if power goes off at 9PM and comes back at 11PM, audio will not be muted when the power comes back.

Hope this helps

share|improve this answer
    
Is this sufficient? What if I power down my machine at 9pm and power it back up at 11pm? The cronjob will not be run. –  noffle Jan 2 '13 at 21:23
    
@noffle No, regular cron will not run missed tasks because of downtime. You might want to look into anacron in order to have this to be more targeted for desktop usage. –  gertvdijk Jan 3 '13 at 0:15
    
@user68186 Looks good, thanks for applying this. I've removed my comment now. –  gertvdijk Jan 3 '13 at 3:38
    
+1 That's a great answer! –  Tom Brossman Jan 4 '13 at 9:31
    
@TomBrossman, Thanks! I had help from the comments by Rinzwind and gertvdijk. –  user68186 Jan 4 '13 at 13:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.