If you already have a script that does program B and have a way to execute it during program A you should be wrap sbatch
around it and periodically submit the job from A instead of running it directly. You may want to check for similar jobs with squeue
before each sbatch to make sure they are not piling up.