Leo
Leo

Reputation: 902

run cron less than a minute in host

I want to run a command on host in less that a minute (for example every 30 second) but I don't have access to ssh. all I have is this. I don't know how to do some hacking with this to run a code in less than a minute.

EDIT1: in this question, I have limited access and I can't run every code(suggested in other questions) in terminal because I don't have access to terminal

Upvotes: 4

Views: 9034

Answers (3)

Thiago Falcao
Thiago Falcao

Reputation: 5013

You can run same job every 30 seconds by using sleep:

* * * * * date >> /tmp/cron.log
* * * * * sleep 30; date >> /tmp/cron.log

Upvotes: 12

Keith Thompson
Keith Thompson

Reputation: 263357

You might be able to fill in the command field with something like:

do_something & sleep 30 ; do_something

The & runs the first command in the background, which lets the second command run at 30 seconds after the minute, not 30 seconds after the first command finishes.

I'm not familiar with the cron interface shown in the image in your question, but if you have the ability to run arbitrary commands in a cron job, you can do just about anything you could do with shell access (just not as conveniently).

Upvotes: 6

sf_admin
sf_admin

Reputation: 577

You can only run cron jobs once per minute. Every 30 seconds is not possible.

This similar question may offer you a workaround: Running a cron every 30 seconds

Upvotes: 1

Related Questions