Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run cron less than a minute in host

Tags:

cron

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

like image 769
Leo Avatar asked Oct 26 '25 14:10

Leo


2 Answers

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

* * * * * date >> /tmp/cron.log
* * * * * sleep 30; date >> /tmp/cron.log
like image 170
Thiago Falcao Avatar answered Oct 29 '25 10:10

Thiago Falcao


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

like image 24
Keith Thompson Avatar answered Oct 29 '25 08:10

Keith Thompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!