I need to use sleep() function but it's disabled

My website URL is: http://skyline.rf.gd/


I have to use sleep function because I tried to control my server via API. First I have to change my server status to Standby then I have to make snapshot. I need 30 seconds delay but I cannot use sleep() command. Actually this is not related with security. Please allow me to use sleep command thanks.

I already saw other discussion about sleep(); and I already explained why I need sleep()İ function. Didn’t see?

Yes, you said you need it for a 30 second delay. But I don’t quite understand why you would ever need a 30 second delay in your web request in the first place. What are you trying to do that you intentionally want to stop a process for 30 seconds?

If you can describe what you are trying to do, maybe we can help you figure out a way to do that without pausing a script for half a minute.

1 Like

Hi again,

I guess I have to explain what am I trying to do from beginning:

I have my own VPS on Scaleway. I have lots of defined settings for my server. Scaleway provide API access. I wrote a php code that control my server via Scaleway API. My code runs only 1st and 15th of every month. Basically my code first change my server status to standby than create snapshot of System Volume. As you know server standby needs time. Around 30 seconds my server goes to standby. That’s why I need sleep(). I fixed my issue but a little bit weird method. I got free hosting from other place. They do not let me use Curl but they allow me to use sleep(). I call a page from there. I made a page called delay.php at free host. So I can able to delay 30 second now. But I have to use that free hosting for just sleep functionality. It is not proper solution. But currently I fixed my issue.

Scaleway on working for hot snapshot. After they fix their problem I can able to make hot snapshot (I do not need to change my server status to standby). But cold snapshot I have to change my server status to standby first.

By the way my server is not hosting server. It is VPN Server. I hope I could explained a little bit why I need sleep();

To be honest disabling sleep(); is not good and it will not increase security. We are all programmers and sleep is the fundamental needs for all programmers.


If my server not goes to standby mode and I try to get snapshot of System Volume I receive an error. That’s why I need 30 seconds for server state change.

I think I understand the reason why you want this.

Unfortunately, I don’t think this is a use case we can make any changes for. Please remember: we provide a website hosting service. A script called through cron to backup a server hosted elsewhere is not exactly a website, and is not a use case we intend to accommodate.

If you add a PHP function to the disable_functions parameter, PHP will say the function was disabled for “security reasons”, regardless of the motivation of the system maintainer.

In this particular case, I would assume the reason sleep() is disabled is because it keeps PHP scripts active, without being counted against the script execution time limit. So for the duration of the sleep() call (which could be VERY long), the PHP process has to be kept alive, it’s memory has to be kept in system memory, it’s connections have to be tracked and so on. An opportunistic hacker could abuse the sleep() call to overload the server with active scripts in a way which shares some similarities with a TCP SYN flood.

This is speculation though. iFastNet disabled the function, we didn’t, but we can assume that they did this for a good reason.

I know, I also have trouble writing good code if I don’t get enough sleep. But I don’t see how the sleep() function in PHP is going to help me with that.

That said, doesn’t Scaleway have a Backups feature which can create backups of your server on a schedule? And a way to convert backups to snapshots? It’s been a while since I’ve used Scaleway, so I don’t know.


Thank you very much for clarification Admin, Scaleway provides API but they do not offer auto backup. Their API includes lots of things. It is easy to do that. Actually I already created Scaleway snapshot generator and I share as a open source:

But it works for Hotsnapshot. Actually Hotsnapshot was working. They temporary problem. Above code can easily make hotsnapshots (You don’t need to change server status)

By the way I like your smart joke :slight_smile:

Anyway thank you very much for your help.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.