run cron less than a minute in host

戏子无情 提交于 2020-07-31 05:43:45

问题


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


回答1:


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




回答2:


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

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



回答3:


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



来源:https://stackoverflow.com/questions/45743423/run-cron-less-than-a-minute-in-host

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!