I am creating a cronjob file to play an audio file in C, bash file is created but redirected output file is not created.
This is my cron job file: musicFile.txt
#!/bin/bash
crontab -l >> alarmFile
55 10 * * * XDG_RUNTIME_DIR=/run/user/$(id -u) play -q /Users/harunsasmaz/Desktop/music.wav > alarmFile
crontab alarmFile
rm -f alarmFile
rm -f musicFile.txt
However, alarmFile
is not created when I run bash musicFile.txt
This is how I am trying to run bash file:
void bashTheCrontab()
{
char *temp[100];
char *text = "bash musicFile.txt";
shapeCrontab(text, temp);
execvp(temp[0], temp);
}
void shapeCrontab(char *text, char *ret[])
{
char arr[100];
strcpy(arr, text);
char *token;
int index = 0;
token = strtok(arr, " ");
while (token != NULL)
{
ret[index] = malloc(sizeof(char) * 100);
strcpy(ret[index++], token);
token = strtok(NULL, " ");
}
}
I probably have some coding mistakes but I cannot figure out.