0

Is it possible with Jenkins to run a command on a specific server at a specific time? For example:

on jenkins@apache-server01i at 10:00   ./stress-ng --cpu 8 --cpu-load 100 --timeout 10m
on jenkins@tomcat-server01i at 11:30    systemctl stop tomcat
on jenkins@tomcat-server01i at 11:35    systemctl start tomcat
on jenkins@mysql-server01i  at 13:00    systemctl restart mysqld

is there a plugin for this Job?

Ian W
  • 4,559
  • 2
  • 18
  • 37

2 Answers2

0

Not really the way Jenkins is intended to be used; better to use cron directly.

Otherwise, set up job with a cron trigger triggers { cron('0 30 * * *') } with an agent labelled to match: agent { node { label 'labelName' } }

You could run one job start at 10, with sleep stages.

Ian W
  • 4,559
  • 2
  • 18
  • 37
0

It's not a bad idea to use a jenkins server as a glorified cron. You get a better insight into jobs running and one place to monitor. You can hook in other plugins to notify you on failure.

It can be good for server restarts, backup jobs, log rotation or file processing jobs, custom service monitoring tests ...

You do introduce a source of failure as if network or ssh connection to host fails then your command will fail. A simple cron job on host does have that advantage.

Two ways it can be done:

  1. Use jenkins Execute Shell plugin. Exchange ssh keys from jenkins -> host and allow ssh access and probably good to configure sudo on host side to allow the specific commands to run.

  2. Use plugin that controls ssh auth configured in jenkins e.g. "Execute shell script on remote host using ssh"

gaoithe
  • 4,218
  • 3
  • 30
  • 38