dsign
dsign

Reputation: 12700

What does this crontab line do?

The script deployment_worker.sh is a control script in charge of stopping and starting a service each two hours... or so I think. Apparently this line in the crontab does something else, judging by the fact that the process comes back from hell pretty fast whenever I kill him:

* */2 * * * /srv/server_ctrl/deployment_worker.sh restart

In line 45 of deployment_worker.sh:

echo "Issuing service start" >> $CONTROL_LOG

I issue a line to the log file, and that line effectively appears in the log, which I think it means this file gets executed by somebody (not me!)... and the only one that comes to my mind is the cron daemon ....

So, here are my questions:

Upvotes: 0

Views: 669

Answers (3)

Joe
Joe

Reputation: 63424

To run once every two hours:

 0   */2   *   *   *   <command-to-run>

So it's running once a minute from 12am to 12:59, then from 2:00am to 2:59, ... etc.

http://livecronjobs.com/how-to-run-cron-every-2-hour

Upvotes: 3

Marc B
Marc B

Reputation: 360762

cron can run a script under whatever uid is necessary. if a common user has cron rights and adds something to their personal crontab, those cron jobs will run under THEIR ids. root can have its own crontab, and also control every other user's crontab as well.

so that cron line of yours could be run as root (if it's in root's crontab), or as some other user.

as for what it does, it runs the specified script every two hours.

Upvotes: 0

Red Cricket
Red Cricket

Reputation: 10470

* */2 * * * mean run at midnight 0, 2 am, 4 am ... see man crontab

Upvotes: 0

Related Questions