0

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

Alavi1412
  • 464
  • 5
  • 26
  • 2
    Possible duplicate of [Running a cron every 30 seconds](https://stackoverflow.com/questions/9619362/running-a-cron-every-30-seconds) – mscheker Aug 17 '17 at 19:30
  • @mscheker you are correct, except for the OP doesn't have access to more advanced features than pure-cron that are suggested there, so the accepted sleep-based solution is the only one appropriate. – Guss Nov 30 '18 at 12:33

3 Answers3

7

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

* * * * * date >> /tmp/cron.log
* * * * * sleep 30; date >> /tmp/cron.log
Thiago Falcao
  • 3,235
  • 31
  • 30
2

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).

Keith Thompson
  • 230,326
  • 38
  • 368
  • 578
1

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

sf_admin
  • 558
  • 3
  • 9