Crontab Shut down command didn't work

4,842

You have configured the crontab wrong do as following:

  1. In terminal type:

    sudo crontab -e
    
  2. Then give the entry for it like:

    30 02 * * * /sbin/shutdown -h now
    
Share:
4,842

Related videos on Youtube

Mat
Author by

Mat

Updated on September 18, 2022

Comments

  • Mat
    Mat over 1 year

    I'm creating an API using C# and ASP.NET Web API and I want it to return an error when a parameter is used that isn't recognised.

    For example:

    /api/Events
    

    should a list of events

    /api/Events?startTime={{startTime}}
    

    should return a list of events that started at a particular time

    /api/Events?someRandomInvalidParameter={{something}}
    

    should return an error

    Is there a nice config way to do this? If not, how can I get a list of parameters to check myself.

  • Admin
    Admin over 10 years
    ok but how to save it in Terminal? because I don't see save function over there.
  • chadwicke619
    chadwicke619 over 10 years
  • chadwicke619
    chadwicke619 over 10 years
    yes it will work every day. Don't need to do anything. See the link above to get more familiar with how to set crontab.
  • Mat
    Mat almost 8 years
    Thanks, Anton. Should this work even in the case where one parameter is valid and one is not? e.g. /api/alive?id=1&blablabla=1 From my limited testing, if I have at least one valid parameter it will still bind to one of my Get methods - could it be because I am using some optional parameters? string startTime = ""
  • Anton Kozlovsky
    Anton Kozlovsky almost 8 years
    Yes it will work because Action will try to find id parameter and will ignore all others. Even localhost:1578/api/alive?qwe=2&id=1 will work.
  • Mat
    Mat almost 8 years
    How can I make it not work? I want the user to be notified if they add qwe=2 and it doesn't do anything.
  • Anton Kozlovsky
    Anton Kozlovsky almost 8 years
    Wait a bit i will investigate this, in my opinion we should change routes
  • Mat
    Mat almost 8 years
    Hi Phong, I want to use parameters because I don't want to explicitly set the URL like that. What if I want to have more than one optional parameter? What about ordering? Also I don't know in advance what invalid parameters people might use.
  • Phong Nguyen
    Phong Nguyen almost 8 years
    This parameter is match with position of value that user input in URL.localhost:8080/app/Events/19901101 localhost:8080/app/Events/19901101/something
  • MarAvFe
    MarAvFe over 5 years
    Ok, done. Also my situation changed since I posted, so check my edit to this answer too.
  • Gertlex
    Gertlex over 2 years
    A key bit I was missing in reading this answer, (after trying my user's crontab with sudo poweroff) was that you want to use the root user's crontab, via sudo. D'oh.