cron job wont run nitrogen --restore - cron

I'm running a linux environment in virtualbox and have installed their guest addition software to be able to resize my vm window when the encapsulating window changes resolution. This works until I want my background to scale.
I'm not really expecting nitrogen to auto-resize but I set up a cron job that I think should have sent the command to restore nitrogen, and fix the backgound, but it doesn't seem to be working. I used * * * * * /bin/nitrogen --restore since I'd like it to run every minute. Another solution is if someone knows how to tack on restoring nitrogen somewhere in the virtualbox guest additions to run on resize.

Related

How can I run a cron job that depends on a desktop without a permanent remote desktop connection open?

I have a virtual machine on a cloud host that stays running in non-desktop mode. It has the Cinnamon desktop environment installed, but I don't typically leave the desktop environment open.
I have a cron job I'd like to run every hour which requires opening an app which requires a desktop environment (headful Chrome).
I've been able to schedule the cron job to use the desktop environment by adding the DISPLAY envvar in the job definition:
1 * * * * DISPLAY=:20 /path/to/script/to/execute
However, this only works when I use remote desktop software to open Cinnamon from my laptop.
I'd like to be able to leave the web server running, without having a remote desktop connection permanently open on my end, and run cron jobs that depend on a desktop environment.
Do y'all have a suggestion for running a cron job as I want to? Maybe a way to leave a desktop environment open without using a remote desktop? Or a way to open a desktop environment within a cron job?
If you don't have a display attached, you'll need to find a headless system that can run with a virtual DISPLAY. Headless Chrome is probably the easiest for you to swap in, and has convenient python bindings [related question].
You might also want to look into running selenium, depending on the task you need to run.
Finally, you might be interested in running a VNC server; depending on the config of your server, you can configure it to stay alive while your client disconnects. usually this is useful for temporary network hiccups, but set to a high enough timeout value, you may get the effects of a persistent, virtual, non-transient display.

How do I create an application that runs in the background and is interactive in Linux?

I want to create an application that runs in the background in Linux (daemon) that will basically at set times (5 times) play a music file or any sound given every single day. I want this daemon to start when the computer is started in terminal mode (non-GUI). I want to know if this is possible and if so, What considerations, tools, and programming language would be the most efficient in doing so? This will be a dedicated computer that will only be executing this task, so if any recommendations on how I can maximize efficiency while disabling other features that are not required for this task will be appreciated. Also, could you please explain how processes and tasks work in terminal (non-GUI)? I always thought terminal was something like CMD in Windows and can only run tasks one at a time.
EDIT: I need the sound to run at variable times, I'll be fetching these times from a website. Any suggestions regarding how to achieve this?
Thanks for the help and sorry for any shortcoming in the questions or my research.
Look at using cron to run your tasks. cron is a very flexible scheduling utility built in to most Linux distributions.
Basically, with cron you specify a task to run (your main program, or maybe just a sound-playing program), all of its arguments, and when it runs. cron takes care of running it, and will even send you "mail" if the job produces any output (such as errors).
You can make processes fork into a subprocess of your terminal, i.e. you are able to run more than one task at a time by putting a & after your terminal command:
> cmd&
> [you can type other commands here but the "cmd" program is still running]
However, for services you generally don't have to worry about starting it as a subprocess because the system already knows to do this. Here's a good question from Super User that has an example of a working service. Simply place your service as a shell script in the /etc/init.d and it will be automatically started as a service.

Trying to launch a process via screen from within ansible

I'm having a slightly weird, repeatable, but unexplainable problem with screen.
I'm using ansible/vagrant to build a consistent dev environment for my company, and as a slightly showy finishing touch it starts the dev server running in a screen session so the frontend devs don't need to bother logging in and manually starting the process, but backend devs can log in and take control.
However, one of the systems - despite being built from scratch - ends up with an immediately dead screen (it doesn't log anything to screenlog). Running the command manually works fine.
(the command being)
screen -L -d -m bash -c /home/vagrant/run_screen_server.sh
I've even gone to the point of nuking everything vagrant/virtualbox related on the system, making sure it's installing a clean, nightly box. Exactly the same source box works all the other machines.
Are there any other debugging steps I can be taking or is there something I'm missing?
I'm right now trying to do the same with my setup and hit the same problem.
Further testing has shown, that sleep 1 right after calling the screen helped. It seems the ssh script that ansible calls exits before the screen call is fully detached (or something else, that would explain that the sleep 1 helps)
I've also found Can't get Fabric's detached screen session example to work with the same suggestion.

oracle temporary ora 12505 error after linux startup

I am experiencing a very strange behavior with oracle, maybe somebody can help me, let me summarize it real quick:
My OS of choice is debian linux, I am using Oracle XE 11.0.2.0. On linux startup, I run a script file which is located under /etc/init.d/. I added the following line to make oracle start on system start:
/etc/init.d/oracle-xe start
Right after this line , I run my application from the script, my application heavily relies on the oracle db, therefore once oracle starts, I am positive that my application will run ok. Unfortunately my assumption seems wrong.Here's why: I set up similar set up in 3 machines, in 2 of them I see weird behavior, after system start oracle db is not responding to connection requests, Even though oracle-xe start command completed executing.
My observation is the following, if I run my application right after oracle-xe start is executed, I receive ora-12505 errors at least for a minute: "TNS listener does not currently know of SID" . After a minute everything stabilizes, and my application starts working ok. 1 minute without a db on system startup is not acceptable for me performance-wise, therefore I am trying to solve this problem.
Surprisingly it does not happen in one of the other linux boxes I have here, I am not quite sure what is different on that box. I compared ora files, but couldn't find any difference, it seems like a wild goose chase...
I would be so grateful if anybody has experienced and solved ths problem before and shares that valuable solution with me.
I think I found the problem, looks like I am starting oracle-xe instance before I assign network interfaces an IP address, in that case it takes some time for oracle to receive connections, that requires me to set static ip on the linux boxes, which is something I don't want. Is there a solution so that I can still assign IP addresses later on?

Creating Back up image of Linux using Altiris DS 6.9 SP5

I am using Altiris Deployment Solution 6.9 SP5. I want to create a back up image of Linux OS/CentOS. I have created the job using the following tasks:
Reboot to automation
Create Disk Image
Reboot
The jobs is stuck at step 2 as the machine goes on sleep immediately after reboot. It tries to send Wake-on-Lan signal but that doesn't work.
Is there a way to keep the system alive until the job completes successfully.
The machine am trying to take back up of is a B series blade server. I could not find any power setting in the BIOS settings to enable Wake-on-Lan.
Please correct me if the process listed above to create a back-up image in DS 6.9 is incorrect.
A quick help is appreciated. Thanks!!
I used the option "Quick Disk Image" (right click on a computer) when i need to perform a backup. Set the job to do not schedule and then configure the task as needed.

Resources