locked
Console Application to be run by Cron RRS feed

  • Question

  • User-1204637165 posted

    Dear All,

    I have just created a console application. The console application is suppose to backup data from my asp.net core LOCAL web app (RUNNING IN A LOCAL AREA NETWORK ) to my online web server.

    I have created the console app to connect to online server. But I dont konw how to start it has a cronjob or do the configuration.

    Please can someone explain to me how to do this.

    Thanks alot.

    Thursday, May 9, 2019 12:09 PM

Answers

  • User911375783 posted

    Hello,

    If you're using Linux then just execute your console application from crontab, if you can't execute it directly then make a script that executes it for you and don't forget to add #!/bin/bash at the beginning. Something like

    #!/bin/sh
    dotnet myapp.dll

    To configure Cron checkout this guide: https://linuxconfig.org/linux-crontab-reference-guide

    If you're on Windows then schedule your console application using Windows Task Scheduler.

    You can obtain the dll by running the following command:

    dotnet publish --output publish --configuration release

    Cheers!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 9, 2019 1:53 PM

All replies

  • User475983607 posted

    Dear All,

    I have just created a console application. The console application is suppose to backup data from my asp.net core LOCAL web app (RUNNING IN A LOCAL AREA NETWORK ) to my online web server.

    I have created the console app to connect to online server. But I dont konw how to start it has a cronjob or do the configuration.

    Please can someone explain to me how to do this.

    Thanks alot.

    If I understand the requirement, the approach is not possible unless you've exposed your local network to the web server.

    Can you explain the problem you are trying to solve?  Are you trying to sync your local database to a remote database?

    Thursday, May 9, 2019 12:23 PM
  • User-1204637165 posted

    yes I am trying to sync local database to online database.

    I felt I could create a cronjob on the local system that would run a background task  that would syncronize the local db to online db.

    So the local network is suppose to have one of their system run a server which would have access to internet. so the cron application would be on the system that as access to internet.

    Thursday, May 9, 2019 12:26 PM
  • User475983607 posted

    What ever system running the scheduled job must have access to the other system.  Generally, a remote web server does not have access to your local network unless you've made configuration changes which is beyond the scope of these forums.

    If you are running SQL server on your local machine then SSIS is an option to move data.

    We have no idea what OS you are running locally.  If Windows then scheduled tasks can be done using Windows task scheduler, SQL Agent, or Visual Studio deployment.

    Thursday, May 9, 2019 12:43 PM
  • User-1204637165 posted

    ON the remote web server I would create a web api. So my Local server can access the remote via. Web Api restful calls.

    I strongly believe that an api call should work out. Doing SQL server configuration makes it very hard to configure when deploying for other clients.

    I want to create a system that I can take and deploy on several client machine without any robust technical configurations.

    As for the Local Cron job. It can connect to the remote server via a RESTFUl Api call.

    Thanks alot.

    Thursday, May 9, 2019 1:11 PM
  • User475983607 posted

    Generally, database are refreshed downward; from production to test, from production to dev, and from production to localhost.  It is very unusual to go from localhost to a remote server unless the application is some kind of logging system or the client application is offline.  If this is the scenario, then certainly CRON can be used to execute code.  But setting up a CRON job on the local machine is beyond the scope of these forums.

    See Linux support for creating a CRON Job.

    Thursday, May 9, 2019 1:38 PM
  • User753101303 posted

    Hi,

    The overall design is unclear. You mean your product is installed locally by multiple unrelated customers and you try to handle "backups" as well for them ? Or tis this rather a kind of "replication" and you address that only at this final step ?

    The "online" version is read only and gather all data from multiple systems or this it just gather backup files just in case?

    Or you installed multiple instances of your app inside the same local network ???

    Thursday, May 9, 2019 1:47 PM
  • User911375783 posted

    Hello,

    If you're using Linux then just execute your console application from crontab, if you can't execute it directly then make a script that executes it for you and don't forget to add #!/bin/bash at the beginning. Something like

    #!/bin/sh
    dotnet myapp.dll

    To configure Cron checkout this guide: https://linuxconfig.org/linux-crontab-reference-guide

    If you're on Windows then schedule your console application using Windows Task Scheduler.

    You can obtain the dll by running the following command:

    dotnet publish --output publish --configuration release

    Cheers!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 9, 2019 1:53 PM
  • User960893937 posted

    You may try Webcron like easycron.com as a cron script trigger.

    Webcron is useful to webmasters. It allows you to launch any script installed on your webserver or shared hosting account at any time. It is a web-based implementation of the Crontab under Unix/Linux and the Task Scheduler under Windows.

    Monday, June 3, 2019 8:17 AM