I have a laravel app. I use a cronjob which runs every 4 hours, and imports csv files and saves in the database.
I have limited times (300 sec max execution time, 60 sec cpu time). The import script should import a lot of csv files (400+).
Is there a way to interrupt before the time runs out and call the import script again? Or how could I solve this so the files can be imported safely?
Probably the best solution if you want to guarantee the process is completed is to use non-overlapping task scheduling. You can read all about it in the documentation:
https://laravel.com/docs/5.2/scheduling#preventing-task-overlaps
It's in fact still a cronjob, but Laravel internally will make sure only one process runs at a time. As such you can still (for example) schedule it to run every minute, so that it immediately restarts after it ends or .. in your situation schedule it to run every 4 hours without the risk of restarting when the previous is not yet done.