Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to come up with a way to repeat things at random intervals. I think I need to use "at" and call an executable file that terminates by placing a new "at" command.
I have a collection of "cute" sounds and I want my box to interesting little noises at odd, infrequent intervals.
This is what I've come up with so far -- creating a file something like this:
- - - - - - - - - - - - - - -
# filename: cute_sounds.txt
# repeats a selected sound at random interval
# as shown, repeats from 1 to 30 days from "now"
# replace "some_cute_sound_file.wav" with the name of the
# sound file to be played
play some_cute_sound_file.wav
at now * (1 + (int) (30.0 * (rand() / (RAND_MAX + 1.0)))) days cute_sounds.txt
- - - - - - - - - - - - - - -
Has anyone done something like this before? Any ideas or tips to help me along the way?
I'm trying to come up with a way to repeat things at random intervals. I think I need to use "at" and call an executable file that terminates by placing a new "at" command.
I have a collection of "cute" sounds and I want my box to interesting little noises at odd, infrequent intervals.
This is what I've come up with so far -- creating a file something like this:
- - - - - - - - - - - - - - -
# filename: cute_sounds.txt
# repeats a selected sound at random interval
# as shown, repeats from 1 to 30 days from "now"
# replace "some_cute_sound_file.wav" with the name of the
# sound file to be played
play some_cute_sound_file.wav
at now * (1 + (int) (30.0 * (rand() / (RAND_MAX + 1.0)))) days cute_sounds.txt
- - - - - - - - - - - - - - -
Has anyone done something like this before? Any ideas or tips to help me along the way?
- Bill
Instead of an at job, why not just make the script sleep for some interval? When you run it, run it with "nohup <script name> > /dev/null 2>&1&" That will background it, with it's own process, so even if you log out, it'll continue to run.
When you run it, run it with "nohup <script name> > /dev/null 2>&1&" That will background it, with it's own process, so even if you log out, it'll continue to run.
Will this last through a reboot? I'm thinking to have the sound(s) repeat at infrequent intervals for the indefinite future. Rebooting would terminate any background process, but I think an at command will run at the scheduled time, even after a reboot.
Can at commands be filed to run after logout? Can they be set to run after login if the set time was missed due to the user being logged out? (Would it be useful to have the command entered as root?)
If you're worried about the command running after reboot, add it to your startup scripts! I don't know Fedora's methodology off the top of my head, but I'm pretty sure they still use rc.local -- this is where you can put custom startup scripts; anything therein is run just before the first login prompt is displayed.
If you're worried about the command running after reboot, add it to your startup scripts! I don't know Fedora's methodology off the top of my head, but I'm pretty sure they still use rc.local -- this is where you can put custom startup scripts; anything therein is run just before the first login prompt is displayed.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.