You can do this by running the task in another instance that runs 24/7, or you can use a third-party service such as Ylastic or Rocket Rush .
If you want to configure it yourself, for example, in C # the code for stopping the server is quite simple:
public void stopInstance (line instance_id, line AWSRegion) {RegionEndpoint myAWSRegion = RegionEndpoint.GetBySystemName (AWSRegion); AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client (AWSAccessKey, AWSSecretKey, myAWSRegion); ec2.StopInstances (new StopInstancesRequest (). WithInstanceId (instance_id)); }
MrGreggs
source share