Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Discuss
  3. How to delete app at a scheduled time on a certain date?

How to delete app at a scheduled time on a certain date?

Scheduled Pinned Locked Moved Solved Discuss
10 Posts 4 Posters 1.9k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • d19dotcaD Offline
    d19dotcaD Offline
    d19dotca
    wrote on last edited by d19dotca
    #1

    Quick question: Is there a way to delete an app at a scheduled time on a certain date in the future?

    For example, I have one app I want to go away on December 31, 2021 this year. While I know I can just do this manually, I thought since it's far into the future maybe I can come up with a geeky way to schedule this task in advance.

    I suppose the best way is using the Cloudron API, right? So I guess it'd be best if I installed the Cloudron API on the server itself (since I won't necessarily have anything running all the time at home here) / CLI, and just set that command in a script and let it run once in cron at the specified time? Any alternatives? Am I overcomplicating this? πŸ˜„

    --
    Dustin Dauncey
    www.d19.ca

    robiR 1 Reply Last reply
    1
    • infogulchI Offline
      infogulchI Offline
      infogulch
      wrote on last edited by
      #2

      Maybe you could disable the app from the inside with a cron job and then clean it up later at your leisure? I'm not exactly sure how you would stop or otherwise disable the app from within without triggering a restart, but maybe there's something in there.

      https://docs.cloudron.io/apps/#cron

      1 Reply Last reply
      2
      • d19dotcaD d19dotca

        Quick question: Is there a way to delete an app at a scheduled time on a certain date in the future?

        For example, I have one app I want to go away on December 31, 2021 this year. While I know I can just do this manually, I thought since it's far into the future maybe I can come up with a geeky way to schedule this task in advance.

        I suppose the best way is using the Cloudron API, right? So I guess it'd be best if I installed the Cloudron API on the server itself (since I won't necessarily have anything running all the time at home here) / CLI, and just set that command in a script and let it run once in cron at the specified time? Any alternatives? Am I overcomplicating this? πŸ˜„

        robiR Offline
        robiR Offline
        robi
        wrote on last edited by robi
        #3

        @d19dotca Yah, you can use N8N to orchestrate it via the cron module and HTTP API call all in their GUI.

        Then share the workflow for others as well.

        Conscious tech

        1 Reply Last reply
        2
        • girishG Offline
          girishG Offline
          girish
          Staff
          wrote on last edited by girish
          #4

          If this is some WordPress app or equivalent, maybe there is some plugin which puts WP in maintenance mode at a particular time.

          But I like @infogulch's idea. Put a cron job inside the app to kill itsef πŸ™‚ To uninstall an app it's a simple curl request:

          curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken
          
          d19dotcaD infogulchI 2 Replies Last reply
          3
          • girishG girish

            If this is some WordPress app or equivalent, maybe there is some plugin which puts WP in maintenance mode at a particular time.

            But I like @infogulch's idea. Put a cron job inside the app to kill itsef πŸ™‚ To uninstall an app it's a simple curl request:

            curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken
            
            d19dotcaD Offline
            d19dotcaD Offline
            d19dotca
            wrote on last edited by
            #5

            @girish oh that’s a lot easier than I thought! Perfect - I’ll try that. πŸ™‚ Thank you so much.

            --
            Dustin Dauncey
            www.d19.ca

            1 Reply Last reply
            0
            • girishG girish

              If this is some WordPress app or equivalent, maybe there is some plugin which puts WP in maintenance mode at a particular time.

              But I like @infogulch's idea. Put a cron job inside the app to kill itsef πŸ™‚ To uninstall an app it's a simple curl request:

              curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken
              
              infogulchI Offline
              infogulchI Offline
              infogulch
              wrote on last edited by infogulch
              #6

              @girish Actually, with a couple improvements, CRON+API could be a wonderfully generalizable app management automation tool.

              Three feature requests:

              • Cloudron doc page on roles should mention the new App Operator role and describe its permissions
              • Add a new environment variable inside each app container, CLOUDRON_APP_ID, which contains the id of the currently running app. This should apply to CRON as well
                • Note: CLOUDRON_API_ORIGIN is already supported
              • Add a new CRON-only environment variable CLOUDRON_APP_OPERATOR_TOKEN which is a temporary "App Operator"-role token that is only valid for the current app and for the duration of the cron run.
                • Depending on how the CRON feature is implemented (is this the cron from inside the container or on the host?) this may not work exactly how I'm thinking.

              With these features, this idea could be implemented much more generally:

              # From this: (user must customize api domain, app id, and token)
              curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken
              # To this: (this is ready to copy/paste for any app in any cloudron, but it stops instead of uninstalls)
              curl -X POST $CLOUDRON_API_ORIGIN/api/v1/apps/$CLOUDRON_APP_ID/stop?access_token=$CLOUDRON_APP_OPERATOR_TOKEN
              

              Thoughts?

              girishG 1 Reply Last reply
              1
              • infogulchI infogulch

                @girish Actually, with a couple improvements, CRON+API could be a wonderfully generalizable app management automation tool.

                Three feature requests:

                • Cloudron doc page on roles should mention the new App Operator role and describe its permissions
                • Add a new environment variable inside each app container, CLOUDRON_APP_ID, which contains the id of the currently running app. This should apply to CRON as well
                  • Note: CLOUDRON_API_ORIGIN is already supported
                • Add a new CRON-only environment variable CLOUDRON_APP_OPERATOR_TOKEN which is a temporary "App Operator"-role token that is only valid for the current app and for the duration of the cron run.
                  • Depending on how the CRON feature is implemented (is this the cron from inside the container or on the host?) this may not work exactly how I'm thinking.

                With these features, this idea could be implemented much more generally:

                # From this: (user must customize api domain, app id, and token)
                curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken
                # To this: (this is ready to copy/paste for any app in any cloudron, but it stops instead of uninstalls)
                curl -X POST $CLOUDRON_API_ORIGIN/api/v1/apps/$CLOUDRON_APP_ID/stop?access_token=$CLOUDRON_APP_OPERATOR_TOKEN
                

                Thoughts?

                girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #7

                @infogulch I mentioned them in the User and the Admin role subsections now.

                Not too sure about new environment variables. It does make sense to add them if there were broad use cases (like other addons), so maybe if more use cases come up, we can add this.

                I like the idea of having some scope for tokens. Restricting them to just specific apps(s) would make things more secure.

                1 Reply Last reply
                2
                • d19dotcaD Offline
                  d19dotcaD Offline
                  d19dotca
                  wrote on last edited by
                  #8

                  @girish said in How to delete app at a scheduled time on a certain date?:

                  curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken

                  Just wanted to say that I ran the above command as a test in a new app for this purpose and it worked like a charm! Thank you so much for that geeky yet easy solution. πŸ™‚

                  --
                  Dustin Dauncey
                  www.d19.ca

                  d19dotcaD 1 Reply Last reply
                  2
                  • d19dotcaD d19dotca

                    @girish said in How to delete app at a scheduled time on a certain date?:

                    curl -X POST https://my.example.com/api/v1/apps/appid/uninstall?access_token=apitoken

                    Just wanted to say that I ran the above command as a test in a new app for this purpose and it worked like a charm! Thank you so much for that geeky yet easy solution. πŸ™‚

                    d19dotcaD Offline
                    d19dotcaD Offline
                    d19dotca
                    wrote on last edited by
                    #9

                    Just to be clear, I suppose the cron time needs to be in UTC? Or does it respect the local time zone instead taken from Cloudron settings?

                    --
                    Dustin Dauncey
                    www.d19.ca

                    girishG 1 Reply Last reply
                    0
                    • d19dotcaD d19dotca

                      Just to be clear, I suppose the cron time needs to be in UTC? Or does it respect the local time zone instead taken from Cloudron settings?

                      girishG Offline
                      girishG Offline
                      girish
                      Staff
                      wrote on last edited by
                      #10

                      @d19dotca yes, UTC

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Bookmarks
                      • Search