Cron daemon not running in debian - linux

I am using Jessie. Cron was working fine last week. But I just checked today and found out, it's not working anymore. When I restart upstart loads my custom tasks. But if I check
sudo service --status-all
Cron is shown marked as [ - ] cron
When I execute sudo service --status-all, I get [FAIL] cron is not running ... failed! in return. Manually starting cron service executes the tasks in crontab. But, the service is not starting on boot.
There is no problem with crontab task specification. They are working fine on my other machines running Ubuntu.

Related

How to disable cron service delay on startup

I'm trying to add the execution of a shell script on server startup. I do it using cron, so I configured it with 'crontab -e' command. It looks so:
#reboot /home/user/run.sh
Then I enabled service with
sudo systemctl enable cron.service
But when I reboot my server, jobs are not started. I check service status with:
sudo systemctl status cron.service
screenshot with an example
And there is a message that it's 2h 55min left to start executing all jobs. So, as I understood service is running but with 3 hours delay. It's happening after every server startup.
Using sudo systemctl restart cron.service command helps to make service working, but the server skips #reboot jobs because "it's not system startup".

Trying to write a shell script to monitor when a service stops in linux, and to automate the restart of this service

So I am relatively new to Centos, version 6.2. I have a service that needs to be mnonitored as a cron job, and if it stops needs to be restarted. I have a few ideas on how to monitor it, but when it comes to getting it restarted thats when I get stuck. I also know the PiD of the service I want to monitor.
You can use supervise for this: http://cr.yp.to/daemontools/supervise.html
Put it in your crontab to launch on system start:
#reboot supervise foo

"Service cron status" command does not give back the status of cron in the ubuntu docker container

I use ubuntu:latest image, cron is already installed, because my cron job doesn't run at all. I want to check if the cron deamon is running in my docker container.
so I type in
service cron status
results in:
Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service cron status
Since the script you are attempting to invoke has been converted to an Upstart job, you may also use the status(8) utility, e.g. status cron
gives me no result of the status of cron, why is that?
The service name is wrong. Here is the fix with crond
service crond status

Alternative for #reboot cron job, start job when cron daemon starts

I have a script which is specified to start on boot-up with the #reboot annotation.
I tried to restart the script by stopping the cron daemon and starting it by entering service crond stop and service crond start, respectively.
However, I noticed that the script doesn't restart at the restarting of the cron daemon, but only when the entire system is rebooted.
My question is, since the cron daemon starts when the system is booted, is there a way start jobs not on reboot but specifically when the cron daemon starts so that service crond stop and service crond start work as expected?
Unfortunately, there is no way to do so,
Cron daemon just ignores #reboot directive
(CRON) INFO (Skipping #reboot jobs -- not system startup)
However, if you're trying to start some script at boot time and have ability to restart it without rebooting the machine, you might want to consider creating either init script or, if you're using systemd, systemd service description.(same with upstart and other init replacements)

Unable to restart rogue Jenkins on Ubuntu

I was configuring Jenkins last night to run some reporting plugins (codestyle, findbugs, cobertura). When I ran my build job it got hung up somewhere in codestyle, and the server ui became unresponsive.
Today I logged in to the server and the Jenkins log is reporting errors that look like the server ran out of memory, but more than that, I cannot seem to stop or restart the server. I have limited experience with services in linux.
Jenkins was installed on Ubuntu with atp. I have tried $ sudo /etc/init.d/jenkins restart but it reports
* Starting Jenkins Continuous Integration Server jenkins
The selected http port (8080) seems to be in use by another program
Please select another port to use for jenkins
When I try to run service jenkins status to get a pid to kill i get
2 instances of jenkins are running at the moment
but the pidfile /var/run/jenkins/jenkins.pid is missing
Running netstat and ps has identified the port being held by a jenkins instance.
How can I recover from this?
Mostly I was concerned about abruptly killing the Jenkins server while it has gone rogue. Something this tied into process with server connections and plugins makes me wary of taking a shotgun to the process.
That's exactly what I did. server jenkins status didn't work, so I got the process id from netstat -tulpn. kill -15 didn't work so I did kill -9, waited a respectful grieving period, then restarted the Jenkins service.
I will next be investigating the root problem of running out of memory in my Jenkins installation so hopefully this doesn't happen again while I am firewalled away from my server.
Where is your server hosted?
I had the same issue with AWS EC2 server.
Command lines did not work to reboot the server.
However, on AWS admin console, I did: EC2 -> restart and it works like a charm.
This may not be a solution but a workaround.
I was able to do
sudo ps aux | grep jenkins
To find a list of jenkins processes. Then I ran
sudo kill <pid>
And then finally
sudo service jenkins restart

Resources