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

SOLVED Support at command in LAMP app

  • Is it possible to enable the at command using a LAMP app?

    I installed it using apt-get in a custom LAMP app, but I cannot enable it or use it. My goal is to schedule a task (run a script) at the indicated time (timestamps are downloaded from a server and may vary from day to day).

    Screen Shot 2020-08-13 at 19.39.47.png

  • Staff

    @alex-adestech Looks like the at command will require a daemon atd to run. Would it be possible to workaround using cron instead? The lamp app has built-in cron support using which you can schedule at any specific time -

  • @girish Well, the thing is that I download a JSON Object with some timestamps indicating the next time the server needs to run a specific script. These timestamps are different each day.

    For example, Monday the 1st should run at 3pm and 5 pm, but next Monday should run at 1pm and 9 pm.

    Could it be possible to edit the crontab file using a script?
    The lamp app needs to restart after cron has changed right?

    Maybe that could be a workaround.

  • Staff

    @alex-adestech Ah, I see. The usual workaround for this is to put a command in crontab like so:

    0 * * * * php /app/data/periodic.php

    The above runs every hour. Then in periodic.php, you can check the current time or some file to see what tasks you want to run etc.

    Would that work?

  • @girish you're a genius man! I think it should work, I'll try it and come back. Thanks!!