Raspberry Pi (RaspBMC) cronjobs not working - settings

I have attempted adding cronjobs via SSH at /etc/crontab and also crontab -e. Neither one seems to work at all!

Activate cron jobs in Raspbmc
Per default running cron jobs is deactivated in Raspbmc and there are two ways to activate them.
- In the Raspbmc GUI under Programs -> Raspbmc Settings -> System Configuration -> Service Management -> Cronjob Scheduler
- Via SSH/FTP by modifying sys.service.cron value to “true” the settings file under /home//.xbmc/userdata/addon_data/script.raspbmc.settings/settings.xml

Since xbmc has been renamed to kodi (version 14.x), the new path is
/home/pi/.kodi/userdata/addon_data/script.raspbmc.settings/settings.xml

Related

run batch script after windows server restart

I am trying to run a script to startup some services after windows reboot.
I have tried one method: copying shortcuts of batch script in shell:startup folder. which eventually will start the scripts automatically but someone has to login to the system.
I am thinking about the possible ways to run the script after server restart without logon to the server.
Any help will be highly appreciated.
Create a Windows scheduled task and set it to run on system startup:

Start ruby app as service on CentOS 7

I have a ruby script (actually an example script from the Oxidized project), which is written in Ruby and opens a UDP port (514) listening for syslog messages and executing some code in the background.
The system runs on CentOS 7. I want to start this script as "service" automatically when the OS boots. The script however needs to run as a specific user (oxidized) and should be controllable using normal "service ... [start|stop|status|...|" behaviour. What would be the best way to achieve this?
Startup services can be managed by 2 different boot systems.
CentOS6 uses System V (Old Boot System)
CentOS7 uses Systemd (New Boot System) (Systemd does support System V scripts.)
Here is a link "How to write startup script for systemd"
https://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd
Here is a link "How to write a System V init script to start, stop, and restart my own application or service"
https://www.cyberciti.biz/tips/linux-write-sys-v-init-script-to-start-stop-service.html

How to cron job setup in Amazon ec2

I have an Amazon EC2 instance running my website. I need to setup a Cron Job to run my file every 12hours.
if file setup via command line so please give a detail step wise.
Does anyone have any advise?
Thanks for your time.
I recently began using Amazon's linux distro on ec2 instances and after trying all kinds of things for cron all I needed was:
sudo service crond start
crontab -e
This allowed me to set a cron job as "ec2-user" without specifying the user. For example:
0 12 * * * python3 example.py
In fact, specifying a user here prevented it from running. I also posted this here.
It's just normal cron.
See: HowTo: Add Jobs To cron Under Linux or UNIX?

Need to restart Jenkins service programmatically on a schedule

I'd like to be able to set up a scheduled job that restarts Jenkins every night (Windows7). Is there a way to set up a job to run that will do a safeRestart programmatically that I can put in my Windows scheduler?
If the above CLI method did not work (in my case it failed on: hudson.security.AccessDeniedException2: anonymous is missing the Overall/Read permission)
You can create a Groovy plugin build step and "Execute a system Groovy script":
import hudson.model.*;
Hudson.instance.doSafeRestart(null);
or the new Jenkins instance
import jenkins.model.*
Jenkins.instance.doSafeRestart(null);
Then, you can set this job to be triggered by schedule.
For example, to restart Jenkins daily on midnight, set "Build periodically": H 00 * * *
Posting this here for others that come here from Google. You can add a job to Jenkins to restart itself using the CLI. Add a job with a shell step to execute:
java -jar "$JENKINS_HOME/war/WEB-INF/jenkins-cli.jar" -s "$JENKINS_URL" safe-restart
You can use the safe-restart command in the Jenkins CLI.
For Jenkins with LDAP enabled, Direct invocation of safe-restart command didn't work. This JENKINS JIRA helped
Login first
java -jar jenkins-cli.jar -s http://localhost:8080 login --username "$JCLIUSER" --password "$JCLIPASSWD"
Safe Restart after that
java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart --username "$JCLIUSER" --password "$JCLIPASSWD"
Solution: Use Jenkins Resftul API in order to restart your jenkins service, and create some crontab task that performs it on daily basis - (On Linux/Unix/Mac versions)
, The basic flags on jenkins related to restarts are:
--restart (force restart , terminating current session)
--safeRestart (restart after all builds and jobs are completed [Graceful restart])
Example:
The task would be:
curl -x POST -u <user>:<token> <jenkins-ip>/safeRestart
For adding a crontab:
#Go to your scripts directory
cd ~/scripts
# edit new script file
sudo vim restart-jenkins-task.sh
# paste the task above ^ ...
# make the script executable
chmod +x restart-jenkins-task.sh
# add crontab task
sudo crontab -e
# paste the following: run the new script every night at 00:00 (12 am midnight)
0 0 * * * ~/scripts/restart-jenkins-task.sh
Pay Attention:
The best practice to manage global maintenance tasks is generating some automation user that deals with the application and maintenance tasks and giving him proper permissions (only users with administrator privilege can perform restart).
For Generating user access with administrator permissions (Manage Jenkins -> Manage and Assign Roles -> Assign Roles -> create user and toggle administrator permission),
For generating access token for authenticating Jenkins from commandline ( Jenkins -> Go to User -> Add new token)

Amazon EC2 automatic reboot and script running

I'm trying to get a amazon ec2 instance to automatically reboot each 2 hours, and after run a shell (.sh) script on startup. Any ideas?
For rebooting after 2 hours, if it is Ubuntu (or Debian based distro) just put on root's cron (by entering sudo crontab -e):
* */2 * * * /sbin/shutdown -r now
I am very curious as to why you need to reboot every 2 hours... I hope this is not a production server... but you could run a cronjob to do the rebooting, what type of instance do you have, is it linux or windows?
I have a centos instance and I have modified /etc/rc.d/rc.local to run a script after booting up but then again you could easily run a script via cronjob to check whether something is running or not...
I guess we need more information from you as to what you are trying to do and what type of instance you have.

Resources